Skip to content

Commit

Permalink
feat(multicolumnautocomplete): first implementation (#670)
Browse files Browse the repository at this point in the history
* feat(multicolumnautocomplete): first implementation

* fix(multicolumnautocomplete): add border right

* fix(autocomplete): fix test and linter errors

* feat(dropdown): add MultiColumn feature to DropdownMenu, Dropdown and ComplexFilter components

* fix(autocomplete): fix autcomplete demo

* refactor(autocomplete): remove AutocompleteBase and AutocompleteMultiColumn exports and stories

and add both under the broader Autocomplete component

* refactor(autocomplete): replace all DefaultDropdownMenuOptions with DefaultAutocompleteOption type

* fix(autocomplete): fix typos and move AutocompleteBase, AutocompleteMultiColumn into

the Autocomplete/components directory

* fix(autocomplete): fix scroll reset bug and design review styles

* fix(dropdownmenu): fix cognetive complexity error

* feat(autocomplete): add custom PopperComponent for Autocomplete, AutocompleteMultiColumn

DropdownMenu and Dropdown components

* fix(storybook): upgrade to the latest version

* refactor(sutocomplete): fix styles and code clean up

BREAKING CHANGE: Autocomplte options type has changed from DefaultDropdownMenuOption to
DefaultAutocompleteOption.

* refactor(autocomplete): use MUI class names object

* fix(autocomplete): remove dead code

* refactor(autocomplete): update comments and code cleanup
  • Loading branch information
masoudmanson authored Nov 22, 2023
1 parent adf650d commit 77342c6
Show file tree
Hide file tree
Showing 37 changed files with 4,240 additions and 2,153 deletions.
1 change: 1 addition & 0 deletions .storybook/manager-head.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<link
href="https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,300;0,400;0,600;0,700;0,800;1,400;1,600;1,700&display=swap"
rel="stylesheet"
crossorigin="anonymous"
/>
<title>SDS Design System</title>
<style>
Expand Down
1 change: 1 addition & 0 deletions .storybook/preview-head.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
<link
href="https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,300;0,400;0,600;0,700;0,800;1,400;1,600;1,700&display=swap"
rel="stylesheet"
crossorigin="anonymous"
/>
41 changes: 23 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"@babel/preset-env": "^7.22.9",
"@babel/preset-react": "^7.22.3",
"@babel/preset-typescript": "^7.21.5",
"@chanzuckerberg/axe-storybook-testing": "^7.1.2",
"@chanzuckerberg/axe-storybook-testing": "^7.1.3",
"@chanzuckerberg/story-utils": "^4.0.0",
"@emotion/core": "^11.0.0",
"@emotion/css": "^11.11.0",
Expand All @@ -21,18 +21,18 @@
"@mui/material": "^5.13.3",
"@rollup/plugin-typescript": "^8.3.1",
"@rollup/plugin-url": "^6.1.0",
"@storybook/addon-a11y": "^7.4.5",
"@storybook/addon-actions": "^7.4.5",
"@storybook/addon-essentials": "^7.4.5",
"@storybook/addon-interactions": "^7.4.5",
"@storybook/addon-links": "^7.4.5",
"@storybook/addon-storyshots": "^7.4.5",
"@storybook/addons": "^7.4.5",
"@storybook/react": "^7.4.5",
"@storybook/react-webpack5": "^7.4.5",
"@storybook/test-runner": "^0.13.0",
"@storybook/testing-library": "^0.2.1",
"@storybook/theming": "^7.4.5",
"@storybook/addon-a11y": "^7.5.3",
"@storybook/addon-actions": "^7.5.3",
"@storybook/addon-essentials": "^7.5.3",
"@storybook/addon-interactions": "^7.5.3",
"@storybook/addon-links": "^7.5.3",
"@storybook/addon-storyshots": "^7.5.3",
"@storybook/addons": "^7.5.3",
"@storybook/react": "^7.5.3",
"@storybook/react-webpack5": "^7.5.3",
"@storybook/test-runner": "^0.15.1",
"@storybook/testing-library": "^0.2.2",
"@storybook/theming": "^7.5.3",
"@svgr/rollup": "^8.0.1",
"@svgr/webpack": "^8.0.1",
"@testing-library/dom": "^9.2.0",
Expand Down Expand Up @@ -77,7 +77,7 @@
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-sonarjs": "^0.19.0",
"eslint-plugin-storybook": "^0.6.14",
"eslint-plugin-storybook": "^0.6.15",
"husky": "^5.1.3",
"jest": "^29.6.2",
"lerna": "^6.5.1",
Expand All @@ -94,9 +94,9 @@
"rollup-plugin-css-only": "^4.3.0",
"rollup-plugin-delete": "^2.0.0",
"rollup-plugin-ts": "^3.2.0",
"storybook": "^7.4.5",
"storybook": "^7.5.3",
"storybook-addon-emotion-theme": "^2.1.1",
"storybook-addon-pseudo-states": "^2.1.1",
"storybook-addon-pseudo-states": "^2.1.2",
"style-dictionary": "^3.0.3",
"stylelint": "^13.11.0",
"stylelint-config-recommended": "^3.0.0",
Expand All @@ -105,6 +105,10 @@
"typescript": "^5.1.3",
"url-loader": "^4.1.1"
},
"resolutions": {
"@types/react": "17.0.2",
"@types/react-dom": "17.0.1"
},
"scripts": {
"start": "storybook dev -p 6006",
"build-storybook": "storybook build -o docs-build",
Expand All @@ -118,7 +122,7 @@
"lint": "lerna run lint",
"build": "lerna run build",
"ci": "yarn install --immutable",
"version:ci":"HUSKY=0 lerna version --yes --conventional-commits",
"version:ci": "HUSKY=0 lerna version --yes --conventional-commits",
"publish:ci": "HUSKY=0 lerna publish from-package --yes"
},
"lint-staged": {
Expand Down Expand Up @@ -150,5 +154,6 @@
"workspaces": [
"packages/*"
],
"main": "index.js"
"main": "index.js",
"dependencies": {}
}
122 changes: 122 additions & 0 deletions packages/components/src/common/AUTOCOMPLETE_MULTI_COLUMN_OPTIONS.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
// (masoudmanson): The unit tests rely on the content in this file; do not alter it!

import Icon from "../core/Icon";

export const AUTOCOMPLETE_MULTI_COLUMN_OPTIONS = [
{
icon: <Icon sdsIcon="chevronRight" sdsSize="xs" sdsType="static" />,
name: "Column One",
options: [
{
name: "Status: can't reproduce",
},
{
name: "Status: confirmed",
},
{
count: 3,
name: "Status: duplicate",
},
{
count: 5,
name: "Status: needs information",
},
{
details: "This will not be worked on",
name: "Status: wont do/fix",
},
{
details: "This is still in progress",
name: "Status: work in progress",
},
],
width: 260,
},
{
icon: <Icon sdsIcon="chevronRight" sdsSize="xs" sdsType="static" />,
name: "Column Two",
options: [
{
details: "This will be worked on",
name: "Type: bug",
},
{
count: 4,
name: "Type: discussion",
},
{
name: "Type: documentation",
},
{
name: "Type: enhancement",
},
{
name: "Type: epic",
},
{
name: "Type: feature request",
},
{
name: "Type: question",
},
],
width: 260,
},
{
name: "Column Three",
options: [
{
name: "Bacteria",
sdsIcon: "bacteria",
sdsIconProps: {
color: "gray",
},
},
{
name: "Puzzle Piece",
sdsIcon: "puzzlePiece",
sdsIconProps: {
color: "gray",
},
},
{
count: 10,
name: "Copy",
sdsIcon: "copy",
sdsIconProps: {
color: "gray",
},
},
{
name: "Light Bulb",
sdsIcon: "lightBulb",
sdsIconProps: {
color: "gray",
},
},
{
count: 6,
name: "List",
sdsIcon: "list",
sdsIconProps: {
color: "gray",
},
},
{
name: "Vertical Tree",
sdsIcon: "treeVertical",
sdsIconProps: {
color: "gray",
},
},
{
name: "Link",
sdsIcon: "link",
sdsIconProps: {
color: "gray",
},
},
],
width: 180,
},
];
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
// (masoudmanson): The unit tests rely on the content in this file; do not alter it!

import { DefaultDropdownMenuOption } from ".";
import Tag from "../Tag";
import Tag from "../core/Tag";

export const GITHUB_LABELS: DefaultDropdownMenuOption[] = [
export const AUTOCOMPLETE_SINGLE_COLUMN_OPTIONS = [
{
name: "Status: can't reproduce",
section: "name only",
Expand Down Expand Up @@ -33,43 +32,61 @@ export const GITHUB_LABELS: DefaultDropdownMenuOption[] = [
section: "name with details",
},
{
details: "This will not be worked on",
name: "Type: bug",
name: "Bacteria",
sdsIcon: "bacteria",
sdsIconProps: {
className: "custom-class-name",
color: "gray",
},
section: "With Icon",
},
{
count: 4,
name: "Type: discussion",
name: "Puzzle Piece",
sdsIcon: "puzzlePiece",
sdsIconProps: {
color: "gray",
},
section: "With Icon",
},
{
name: "Type: documentation",
count: 10,
name: "Copy",
sdsIcon: "copy",
sdsIconProps: {
color: "gray",
},
section: "With Icon",
},
{
name: "Type: enhancement",
name: "Light Bulb",
sdsIcon: "lightBulb",
sdsIconProps: {
color: "gray",
},
section: "With Icon",
},
{
name: "Type: epic",
count: 6,
name: "List",
sdsIcon: "list",
sdsIconProps: {
color: "gray",
},
section: "With Icon",
},
{
name: "Type: feature request",
name: "Vertical Tree",
sdsIcon: "treeVertical",
sdsIconProps: {
color: "gray",
},
section: "With Icon",
},
{
name: "Type: question",
sdsIcon: "search",
name: "Link",
sdsIcon: "link",
sdsIconProps: {
color: "gray",
},
section: "With Icon",
},
{
Expand All @@ -82,18 +99,21 @@ export const GITHUB_LABELS: DefaultDropdownMenuOption[] = [
sdsStyle="rounded"
sdsType="secondary"
color="error"
hover={false}
/>
<Tag
label="feature"
sdsStyle="rounded"
sdsType="secondary"
color="warning"
hover={false}
/>
<Tag
label="refactor"
sdsStyle="rounded"
sdsType="secondary"
color="gray"
hover={false}
/>
</div>
</div>
Expand Down
2 changes: 2 additions & 0 deletions packages/components/src/common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ export const noop = (): void => {};

export const toKebabCase = (str: string) =>
str.replace(/[\s_]+/g, "-").toLowerCase();

export const EMPTY_OBJECT = {};
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,7 @@ const OPTIONS = [
];

const AutocompleteNameSpaceTest = (
props: AutocompleteProps<
DefaultAutocompleteOption,
true,
undefined,
undefined
>
props: AutocompleteProps<DefaultAutocompleteOption, true, false, false>
) => {
return (
<Autocomplete
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

exports[`<Autocomplete /> Default story renders snapshot 1`] = `
<div
style="margin: 16px 0px 0px 24px; width: 300px;"
style="margin: 16px 0px 0px 24px; width: 274px;"
>
<div
class="MuiAutocomplete-root MuiAutocomplete-hasPopupIcon css-t46og2-MuiAutocomplete-root"
class="MuiAutocomplete-root MuiAutocomplete-hasPopupIcon css-kwza7v-MuiAutocomplete-root"
label="Search by label"
>
<div
Expand Down Expand Up @@ -84,8 +84,5 @@ exports[`<Autocomplete /> Default story renders snapshot 1`] = `
</div>
</div>
</div>
<div
style="margin-top: 10px;"
/>
</div>
`;
Loading

0 comments on commit 77342c6

Please sign in to comment.