1.4.0 • Published 9 months ago

commandk v1.4.0

Weekly downloads
-
License
MIT
Repository
-
Last release
9 months ago

Table of contents

Features

Currently, commandK supports the following:

  • Open the popup using Command + K
  • Filter items based on search terms
  • Supports 3 sizes for the modal (medium, large and small)
  • Supports custom styles
  • Navigation with keyboard
  • Mobile responsive
  • Light mode support

You can suggest new features here

Installation

Package Managers

# npm
npm i commandk

# yarn
yarn add commandk

# pnpm
pnpm i commandk

Usage

import { CommandK } from 'commandk'

<CommandK data={[]} />

Or you can access the Modal component and Button component separately and implement your own logic.

import React from "react"
import { Modal, Button } from 'commandk'

const App = () => {

  const [isOpen, setIsOpen] = React.useState<boolean>(false);

  return (
    <>
      {isOpen && <Modal data={[]} toggle={() => setIsOpen(false)} />}
      <Button onClick={() => setIsOpen(true)} />
    </>
  )
}

export default App;

Data

Structure of the data that's taken by the component,

TS Definition

export interface Item {
  icon: string
  title: string
  url?: string
}

interface Group {
  sectionName: string
  items: Item[]
}

Sample

const list: Group[] = [
  {
    sectionName: 'Repositories',
    items: [
      {
        icon: '🗂',
        title: 'This is a test title',
        url: '/repo',
      },
      {
        icon: '🚀',
        title: 'This is another one to check',
        url: 'https://google.lk',
      },
    ],
  },
]

API

CommandK

ParameterDescriptionTypeDefault
datadata needed to populate the search modalArray[]
keyLetterkey that needs be appear on the buttonstringK
buttonSizesize of the buttonsmall medium largemedium
modalSizesize of the modalsmall medium largemedium
usernamename of the search modalstringhome
perSectionLimitlimit numner of items in a sectionnumber-
customStylesthe style of the componentObject{}

Modal

ParameterDescriptionTypeDefault
datadata needed to populate the search modalArray[]
isOpento open and close the modalbooleanfalse
sizesize of the modalsmall medium largemedium
usernamename of the search modalstringhome
perSectionLimitlimit numner of items in a sectionnumber-
toggleclose the modalFunction() => null

Button

ParameterDescriptionTypeDefault
keyLetterkey that needs be appear on the buttonstringK
sizesize of the modalsmall medium largemedium
stylesthe style of the componentObject{}
toggleopen the modalFunction() => null

Local Development

The main branch contains the latest version of the CommandK component.

To begin local development:

  1. yarn install
  2. yarn run storybook

Storybook will appear on on http://localhost:6006

You can run yarn test to execute the test suite and linters. To help you develop the component we’ve set up some tests that cover the basic functionality (can be found in <component>/__tests__). To check the test coverage you can run yarn coverage.

Accessibility

Keyboard support

  • Down: Navigate through the searched items
  • Up: Navigate through the searched items
  • Enter: Jump to the selected page/url
  • Command/K: open and close the search modal

Contributing

Contributions are welcome! If you have any ideas, bug reports, or feature requests, please submit them through the GitHub issue tracker. If you would like to contribute code, follow these steps:

  1. Fork the repository.
  2. Create a new branch for your feature or bug fix.
  3. Make the necessary changes and commit them.
  4. Push your changes to your forked repository.
  5. Submit a pull request to the main repository.

License

This project is licensed under the MIT License. You can find more information in the LICENSE file.

If you need to reach out to me contact me.

1.4.0

9 months ago

1.3.9

9 months ago

1.3.8

9 months ago

1.3.7

9 months ago

1.3.6

9 months ago

1.3.5

9 months ago

1.3.4

9 months ago

1.3.3

9 months ago

1.3.2

9 months ago

1.3.1

9 months ago

1.3.0

9 months ago

1.2.9

9 months ago

1.2.8

9 months ago

1.2.7

9 months ago

1.2.6

9 months ago

1.2.5

9 months ago

1.2.4

9 months ago

1.2.3

9 months ago

1.2.2

9 months ago

1.2.1

9 months ago

1.1.9

9 months ago

1.1.8

9 months ago

1.1.7

9 months ago

1.1.6

9 months ago

1.1.5

9 months ago

1.1.4

9 months ago

1.1.3

9 months ago

1.1.2

9 months ago

1.1.1

9 months ago

1.1.0

9 months ago

1.0.8

9 months ago

1.0.7

9 months ago

1.0.6

9 months ago

1.0.5

9 months ago

1.0.4

9 months ago

1.0.3

9 months ago

1.0.2

9 months ago

1.0.1

9 months ago

1.0.0

9 months ago

1.2.0

1 year ago