Skip to content

Commit

Permalink
0.8.x (#12)
Browse files Browse the repository at this point in the history
* feat: add searchable-checkbox-list and update action-bar

* feat: add fitler-list, header-mobile, header-nav, preview components doc

* feat: fix spelling error

* feat: fix pr from Quentin

* feat: fix pr from Quentin
  • Loading branch information
vapersmile authored Jan 12, 2024
1 parent 6b567b0 commit 15dc9f2
Show file tree
Hide file tree
Showing 7 changed files with 230 additions and 11 deletions.
15 changes: 8 additions & 7 deletions docs/components/01-action-bar.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@

ActionBar takes a `<Data>` generic type that extends `Record<string, unknown>`.

| Name | Type | Default | Description |
| --------------------------------- | -------------------------------------------------------------- | ------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| selectedElements <Required/> | `Data[]` | - | Array of currently selected elements, necessary for the `actions` to be able to pass those elements along |
| selectedElementsLabel <Required/> | `(selectedElements: number) => string` | ``(selectedElements: number) => `${selectedElements} file(s) selected` `` | Function used to generate the string that displays how many elements are currently selected, it gives the current number of elements in the `selectedElements` array as a parameter |
| actions | [`IAction`](./thumbnail#ithumbnailaction) `<Data \| Data[]>[]` | - | Array of [`IAction`](../shared-types/actions#iactiont) for mass action shown in the bar |
| modalProps | [`IThumbnailAction[]`](./thumbnail#ithumbnailaction) | - | Extra props passed to the internal [Mantine Modal](https://v6.mantine.dev/core/modal/) component, used for actions with confirmation enabled |
| ... | - | - | extends [Group props](https://v6.mantine.dev/core/group/?t=props) |
| Name | Type | Default | Description |
| --------------------------------- | -------------------------------------------------------------- | ----------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| selectedElements <Required/> | `Data[]` | - | Array of currently selected elements, necessary for the `actions` to be able to pass those elements along |
| selectedElementsLabel <Required/> | `(selectedElements: number) => string` | ``(selectedElements: number) => `${selectedElements} file(s) selected`` | Function used to generate the string that displays how many elements are currently selected, it gives the current number of elements in the `selectedElements` array as a parameter |
| actions | [`IAction`](./thumbnail#ithumbnailaction) `<Data \| Data[]>[]` | - | Array of [`IAction`](../shared-types/actions#iactiont) for mass action shown in the bar |
| modalProps | [`IThumbnailAction[]`](./thumbnail#ithumbnailaction) | - | Extra props passed to the internal [Mantine Modal](https://v6.mantine.dev/core/modal/) component, used for actions with confirmation enabled |
| rowActionNumber | `number` | `1` | Index value used to determine which actions will be displayed directly in the action column (before this index) or in the action menu (starting at this index) |
| ... | - | - | extends [Group props](https://v6.mantine.dev/core/group/?t=props) |
62 changes: 62 additions & 0 deletions docs/components/01-filter-list.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Filter List

<Description
extendsInfo={[
{
label: 'Stack',
link: 'https://v6.mantine.dev/core/stack/',
},
{
label: 'Container',
link: 'https://v6.mantine.dev/core/container/',
},
{
label: 'Modal',
link: 'https://v6.mantine.dev/core/modal/',
},
{
label: 'SearchableCheckboxList',
link: 'https://smile-sa.github.io/react-front-kit/?path=/docs/3-custom-components-searchablecheckboxlist--docs',
},
]}
importExample="import { FilterList } from '@smile/react-front-kit';"
packageInfo={{
label: '@smile/react-front-kit',
link: 'https://www.npmjs.com/package/@smile/react-front-kit',
}}
sourceInfo={{
link: 'https://github.com/Smile-SA/react-front-kit/blob/main/packages/react-front-kit/src/Components/FilterList/FilterList.tsx',
}}
>
Renders a list of filters with text inputs and a manage filters button which
displays the component
[SearchableCheckboxList](../components/searchable-checkbox-list)
</Description>

## Storybook Docs

<StorybookEmbed storyId="3-custom-components-filterlist--docs" height="1600" />

## Props

| Name | Type | Default | Description |
| ---------------------------------- | -------------------------------------- | --------------------- | --------------------------------------------------------------------- |
| filters <Required/> | `IFilter[] | - | Array of filters |
| onActiveFiltersChange | `((filters: IFilter[]) => void)` | - | Callback function called when the `confirm change` button is clicked. |
| onSubmit | `((activeFilters: IFilter[]) => void)` | - | Callback function called when the `submit` button is clicked. |
| direction | `"row" \| "column"` | `"row"` | Display orientation |
| filtersManageLabel | `string` | `"Manage filters"` | Label of filters manage button |
| manageFilterModalSearchPlaceholder | `string` | `"Search in filters"` | Placeholder of filter modal search |
| manageFilterModalSearchSubmit | `string` | `"Confirm changes"` | Label of confirm change button in modal |
| manageFilterModalTitle | `string` | `"Manage filters"` | Title of manage filter modal |
| modalProps | `ModalProps` | - | Props of [Modal](https://v6.mantine.dev/core/modal/) component |
| submitLabel | `string` | `"Filter"` | Submit button label |

### `IFilter`

| Attribute | Type | Description |
| ----------------- | ------------------ | -------------------------- |
| active | `boolean` | Define if filter is active |
| component | `ReactElement` | component element |
| id <required/> | `number \| string` | identifier |
| label <required/> | `string` | Label value |
41 changes: 41 additions & 0 deletions docs/components/01-header-mobile.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Header Mobile

<Description
extendsInfo={[
{
label: 'AppShell (Header)',
link: 'https://v6.mantine.dev/core/app-shell/',
},
]}
importExample="import { HeaderMobile } from '@smile/react-front-kit';"
packageInfo={{
label: '@smile/react-front-kit',
link: 'https://www.npmjs.com/package/@smile/react-front-kit',
}}
sourceInfo={{
link: 'https://github.com/Smile-SA/react-front-kit/blob/main/packages/react-front-kit/src/Components/HeaderMobile/HeaderMobile.tsx',
}}
>
Render an application header with optional left section, right section,
content and search button/bar for mobile display
</Description>

## Storybook Docs

<StorybookEmbed
storyId="3-custom-components-headermobile--docs"
height="2110"
/>

## Props

| Name | Type | Default | Description |
| -------------- | ---------------------------- | ------- | ---------------------------------------------------------------------------------------------------- |
| children | `ReactNode` | - | Main content of header |
| height | `number` | `90` | Height of Header |
| left | `ReactNode` | - | Left section |
| right | `ReactNode` | - | Right section |
| searchValue | `string` | - | Controlled value of search bar input |
| onSearchSubmit | `(event: FormEvent) => void` | - | Called when search bar input is submitted |
| WithBorder | `boolean` | `false` | Display or not a border on the Header |
| ... | - | - | extends [Mantine's HeaderProps](https://v6.mantine.dev/core/app-shell/?t=props#headercomponentprops) |
36 changes: 36 additions & 0 deletions docs/components/01-header-nav.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Header Nav

<Description
importExample="import { HeaderNav } from '@smile/react-front-kit';"
packageInfo={{
label: '@smile/react-front-kit',
link: 'https://www.npmjs.com/package/@smile/react-front-kit',
}}
sourceInfo={{
link: 'https://github.com/Smile-SA/react-front-kit/blob/main/packages/react-front-kit/src/Components/HeaderNav/HeaderNav.tsx',
}}
>
Renders a list of menus as either a horizontal list of NavLink components or a
vertical SidebarMenu in mobile mode
</Description>

## Storybook Docs

<StorybookEmbed storyId="3-custom-components-headernav--docs" height="1210" />

## Props

| Name | Type | Default | Description |
| ----------------- | --------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------ |
| menus <required/> | `IHeaderNavMenu<T>[]` | - | Array of menu objets to be rendered in vertical or horizontal lists |
| isMobile | `boolean` | `false` | Determines if the menus will be displayed as a horizontal list of NavLink components (desktop) or as a vertical SidebarMenu (mobile) |
| navLinkComponent | `ElementType` | `"a"` | Type of Element tag used for the NavLink components |

## IHeaderNavMenu

`IHeaderNavMenu` has a generic `T` that extend of `number | string` and it extend of `IMenuItem<T>`

| Name | Type | Description |
| -------- | --------------------- | ------------------------------------------------ |
| children | `IHeaderNavMenu<T>[]` | Object array to be rendered in a header sub-menu |
| url | `string` | the url of the navigation link |
29 changes: 29 additions & 0 deletions docs/components/01-preview.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Preview

<Description
importExample="import { Preview } from '@smile/react-front-kit';"
packageInfo={{
label: '@smile/react-front-kit',
link: 'https://www.npmjs.com/package/@smile/react-front-kit',
}}
sourceInfo={{
link: 'https://github.com/Smile-SA/react-front-kit/blob/main/packages/react-front-kit/src/Components/Preview/Preview.tsx',
}}
>
Renders a preview of different types (image, video, audio or an iframe for any
other types) from a source URL
</Description>

## Storybook Docs

<StorybookEmbed storyId="3-custom-components-preview--docs" height="4490" />

## Props

| Name | Type | Default | Description |
| ------------------ | -------- | ------- | --------------------------------------- |
| url <Required/> | `string` | - | Source url |
| defaultAspectRatio | `number` | - | Default default aspect ratio of preview |
| defaultHeight | `number` | - | Default height of the preview |
| defaultMimeType | `string` | - | Default mime type of the preview |
| defaultWidth | `number` | - | Default width of the preview |
41 changes: 41 additions & 0 deletions docs/components/01-searchable-checkbox-list.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Searchable Checkbox List

<Description
extendsInfo={[]}
importExample="import { searchablecheckboxlist } from '@smile/react-front-kit';"
packageInfo={{
label: '@smile/react-front-kit',
link: 'https://www.npmjs.com/package/@smile/react-front-kit',
}}
sourceInfo={{
link: 'https://github.com/Smile-SA/react-front-kit/blob/main/packages/react-front-kit/src/Components/SearchableCheckboxList/SearchableCheckboxList.tsx',
}}
>
Renders a search bar with checkboxes and a validation button
</Description>

## Storybook Docs

<StorybookEmbed
storyId="3-custom-components-searchablecheckboxlist--docs"
height="820"
/>

## Props

`T` extends ICheckbox

| Name | Type | Default | Description |
| ------------- | ----------------------------- | --------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
| checkboxes | `T[]` | - | Object array that displays a list of checkboxes with their values and labels in different rows if they are activated or not. |
| buttonLabel | `string` | `"Validate changes"` | Label of button |
| onClickButton | `((checkboxes: T[]) => void)` | - | Called when the confirm button is clicked |
| placeholder | `string` | `"Search in options"` | placeholder of input text |

## ICheckbox

| Attribute | Type | Description |
| ------------------ | ------------------ | ------------------------------------------------------------------ |
| active | `boolean` | Controlled value that determines if the Checkbox is checked or not |
| id <Required/> | `number \| string` | Id of the checkbox |
| label: <Required/> | 'string' | Label of the Checkbox |
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
# Filters Bar
# Sidebar Filters

<Description
importExample="import { FiltersBar } from '@smile/react-front-kit';"
extendsInfo={[
{
label: 'CollapseButtonControlled',
link: 'https://v6.mantine.dev/core/group/',
},
]}
importExample="import { SidebarFilters } from '@smile/react-front-kit';"
packageInfo={{
label: '@smile/react-front-kit',
link: 'https://www.npmjs.com/package/@smile/react-front-kit',
}}
sourceInfo={{
link: 'https://github.com/Smile-SA/react-front-kit/blob/main/packages/react-front-kit/src/Components/FiltersBar/FiltersBar.tsx',
link: 'https://github.com/Smile-SA/react-front-kit/blob/main/packages/react-front-kit/src/Components/SidebarFilters/SidebarFilters.tsx',
}}
>
Renders a column of nested menus containing filters with a submit button,
Expand All @@ -16,7 +22,10 @@

## Storybook Docs

<StorybookEmbed storyId="3-custom-components-filtersbar--docs" height="4380" />
<StorybookEmbed
storyId="3-custom-components-sidebarfilters--docs"
height="4380"
/>

## Props

Expand Down

0 comments on commit 15dc9f2

Please sign in to comment.