Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Dropdown] Updated stylings, states and stories #176

Merged
merged 30 commits into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
9dd13d4
feat: Dropdown Updated - styling, error prop, story
shindigira Sep 19, 2023
0c9a7fb
fix: [Dropdown] Add intro paragraph
meissadia Sep 19, 2023
e1ceb2e
chore: utlized external state in Checkbox
shindigira Sep 21, 2023
05dd65d
chore: removed the use of defaultChecked and internal usestate -- Che…
shindigira Sep 21, 2023
a013927
style: styled the dropdown option menu, Checkboxes and option text to…
shindigira Sep 21, 2023
85d2a68
style: hovering entire option line causes checkbox to have a blue box…
shindigira Sep 21, 2023
e755e25
refactor: removed defaultValue as a prop, removed internal state from…
shindigira Sep 22, 2023
0d4f01e
chore: added @storybook/client-api -- for useArgs
shindigira Sep 22, 2023
0017314
feat: Modified all of Dropdown.stories to use useArg (state)
shindigira Sep 22, 2023
6b5ef8a
chore: updated the stories of Checkbox and Dropdown
shindigira Sep 22, 2023
caaf724
rebased from main
shindigira Sep 22, 2023
03fab6f
style: adjusted error border-width style
shindigira Sep 22, 2023
2bda2a4
style: adjust error style -- part 2
shindigira Sep 22, 2023
148623f
chore: updated react-select styling to not have extra border when isC…
shindigira Sep 22, 2023
53cc011
chore: adjusted story labels
shindigira Sep 22, 2023
50141e3
chore: Updated Dropdown stories
shindigira Sep 23, 2023
d325a07
chore: Renamed Dropdown stories
shindigira Sep 25, 2023
3c5ac3b
chore: Utilized the dotted accessbility styling in the Options
shindigira Sep 25, 2023
695e29c
style: updated the styling to not have the underneath grey border und…
shindigira Sep 25, 2023
744fc22
chore: removed comments and dead code
shindigira Sep 25, 2023
3c14481
Removed 'dropdown-control:hover' style from Dropdown.less
shindigira Sep 26, 2023
467c737
chore: disabled the X in Dropdown by default
shindigira Sep 26, 2023
f9a9f74
Merge branch '173-Dropdown-Update' of github.com:cfpb/design-system-r…
shindigira Sep 26, 2023
18b667c
chore: disable the X by default at the component level
shindigira Sep 26, 2023
1623b9b
chore: removed inline clearAll Dropdown story
shindigira Sep 26, 2023
cf1692b
fix: removed default id that would brake Dropdown stories
shindigira Sep 26, 2023
a878823
fix: Interactions on Overview page visibly update the component
meissadia Sep 26, 2023
871dd62
fix: Delete custom clear indicator
meissadia Sep 26, 2023
01a921a
fix: [Dropdown] Remove extra grey border when in Error state
meissadia Sep 26, 2023
6d2bc97
fix: Remove custom styling for Dropdown clear "X"
meissadia Sep 26, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@
"@cfpb/cfpb-design-system": "^0.29.0",
"@cfpb/cfpb-expandables": "^0.29.0",
"@cfpb/cfpb-forms": "^0.29.0",
"@storybook/jest": "^0.2.2",
"@storybook/testing-library": "^0.2.1",
"@tanstack/react-query": "4.13.5",
"@tanstack/react-table": "^8.8.0",
"classnames": "^2.3.2",
Expand All @@ -67,9 +65,12 @@
"@storybook/addon-essentials": "^7.0.6",
"@storybook/addon-interactions": "^7.4.3",
"@storybook/addon-links": "^7.0.6",
"@storybook/client-api": "^7.4.3",
"@storybook/jest": "^0.1.0",
"@storybook/manager-api": "^7.3.2",
"@storybook/react": "^7.0.6",
"@storybook/react-vite": "^7.0.6",
"@storybook/testing-library": "^0.1.0",
"@storybook/theming": "^7.3.2",
"@testing-library/cypress": "8.0.7",
"@testing-library/dom": "8.19.0",
Expand Down
53 changes: 48 additions & 5 deletions src/components/Checkbox/Checkbox.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,64 @@
/* eslint-disable unicorn/prevent-abbreviations */
meissadia marked this conversation as resolved.
Show resolved Hide resolved
/* eslint-disable react/jsx-handler-names */
import type { Meta, StoryObj } from '@storybook/react';
import { Checkbox } from '~/src/index';
import { Checkbox } from './Checkbox';

import { useArgs } from '@storybook/client-api';

const meta: Meta<typeof Checkbox> = {
title: 'Components/Checkbox',
component: Checkbox,
argTypes: {
disabled: { control: 'boolean' },
isLarge: { control: 'boolean' }
parameters: {
docs: {
description: {
component: `Checkbox Component`
}
}
}
};

export default meta;

type Story = StoryObj<typeof meta>;

interface CheckboxWrapperProperties {
id: string;
label: string;
}

function CheckboxWrapper({
id,
label,
...arguments_
}: CheckboxWrapperProperties): JSX.Element {
const [{ checked }, updateArgs] = useArgs();
return (
<Checkbox
{...arguments_}
id={id}
label={label}
onChange={(): void =>
updateArgs({
checked: !checked
})
}
/>
);
}

export const DefaultCheckbox: Story = {
args: { id: 'default', name: 'default', label: 'Default checkbox' }
render: _args => CheckboxWrapper(_args),
name: 'Default dropdown',
meissadia marked this conversation as resolved.
Show resolved Hide resolved
args: {
id: 'default',
name: 'default',
label: 'Default checkbox',
checked: false
}
};

export const CheckboxWithHelper: Story = {
render: _args => CheckboxWrapper(_args),
args: {
...DefaultCheckbox.args,
id: 'CheckboxWithHelper',
Expand All @@ -28,6 +69,7 @@ export const CheckboxWithHelper: Story = {
};

export const LargeCheckbox: Story = {
render: _args => CheckboxWrapper(_args),
args: {
...DefaultCheckbox.args,
id: 'LargeCheckbox',
Expand All @@ -38,6 +80,7 @@ export const LargeCheckbox: Story = {
};

export const LargeCheckboxWithHelper: Story = {
render: _args => CheckboxWrapper(_args),
args: {
...DefaultCheckbox.args,
id: 'LargeCheckboxWithHelper',
Expand Down
23 changes: 10 additions & 13 deletions src/components/Checkbox/Checkbox.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import classnames from 'classnames';
import type React from 'react';
import { useMemo, useState } from 'react';
import type { ReactNode } from 'react';
import { useCallback } from 'react';

interface CheckboxProperties extends React.HTMLProps<HTMLInputElement> {
id: string;
label: string;
label: ReactNode;
className?: string;
defaultChecked?: boolean;
helperText?: string;
inputClassName?: string;
inputRef?:
Expand All @@ -18,14 +18,15 @@ interface CheckboxProperties extends React.HTMLProps<HTMLInputElement> {
isLarge?: boolean;
name?: string;
}

const containerBaseStyles = ['m-form-field m-form-field__checkbox'];

export const Checkbox = ({
id,
label,
className,
inputClassName,
defaultChecked = false,
checked = false,
helperText,
inputRef,
disabled = false,
Expand All @@ -34,15 +35,11 @@ export const Checkbox = ({
onChange,
...properties
}: CheckboxProperties & JSX.IntrinsicElements['input']): React.ReactElement => {
const [checked, setChecked] = useState(defaultChecked);

const onChangeHandler = useMemo(
() =>
(event: React.ChangeEvent<HTMLInputElement>): void => {
setChecked(event.target.checked);
onChange?.(event);
},
[onChange, setChecked]
const onChangeHandler = useCallback(
(event: React.ChangeEvent<HTMLInputElement>): void => {
onChange?.(event);
},
[onChange]
);

const containerClasses = [
Expand Down
52 changes: 52 additions & 0 deletions src/components/Dropdown/Dropdown.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
.dropdown-control {
border-radius: 0 !important;
border-width: 1px !important;
width: 100% !important;
border-color: #919395 !important;
// outline: solid #919395 !important;
meissadia marked this conversation as resolved.
Show resolved Hide resolved
}

.dropdown-control:hover {
outline: 2px solid #0072ce;
outline-offset: 0;
}

.dropdown-indicator-separator {
margin-top: 0 !important;
margin-bottom: 0 !important;
background: #919395 !important;
border-color: inherit !important;
width: 1px !important;
}

.dropdown-indicator-separator__none {
width: 0px !important;
}

.dropdown-indicators-container {
background: #e7e8e9 !important;
border-left: #919395 1px solid;
}

.dropdown-dropdown-indicator {
color: inherit !important;
border-color: inherit !important;
}

.dropdown-value-container {
}
meissadia marked this conversation as resolved.
Show resolved Hide resolved

.dropdown-value-container--error {
border-style: solid !important;
border-color: #d14124 !important;
// outline: solid #d14124 !important;
meissadia marked this conversation as resolved.
Show resolved Hide resolved
border-width: 0.17em !important;
}

.dropdown-value-container--success {
}
meissadia marked this conversation as resolved.
Show resolved Hide resolved

.dropdown-clear-indicator-container {
margin-left: 4px;
margin-right: 4px;
}
Loading