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

chore: Fix GroupHeading props + some other cleanup #296

Merged
merged 8 commits into from Oct 27, 2023
Merged

Conversation

csandman
Copy link
Owner

closes #295


This PR is in response to #295. I had already found the fix for this issue, so this PR just implements it. The solution was just to implement some code I had missed from the original GroupHeading component.

It also implements a few other cleanup changes:

  • Simplify the theme types by using Chakra's built in ThemeTypings interface.
  • Update a few TSDoc comments and their links
  • Unify some variable names and types
  • Add some aria props and change some of the style configs to use them. This was initially proposed in fix: use correct aria roles for menu #283, and the changes were cherry picked from the other branch I'm working on.

Here's a recreation of the demo linked in the issue, see below for the updated sandbox: https://codesandbox.io/s/msxddg?file=/ChakraAccordion.tsx

@codesandbox-ci
Copy link

codesandbox-ci bot commented Oct 26, 2023

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit e434952:

Sandbox Source
chakra-react-select demo Configuration
chakra-react-select TS demo Configuration
chakra-react-select + next.js Configuration
chakra-react-select + next.js + typescript Configuration
chakra-react-select - Heading Props Example PR

@github-actions
Copy link

github-actions bot commented Oct 26, 2023

📊 Package size report   1%↑

File Before After
dist/cjs/chakra-components/control.js 10.3 kB 3%↑10.6 kB
dist/cjs/chakra-components/control.js.map 19.1 kB 2%↑19.6 kB
dist/cjs/chakra-components/input.js 3.5 kB -4.39%↓3.3 kB
dist/cjs/chakra-components/input.js.map 6.5 kB -3.88%↓6.2 kB
dist/cjs/chakra-components/menu.js 11.7 kB 6%↑12.3 kB
dist/cjs/chakra-components/menu.js.map 22.8 kB 4%↑23.8 kB
dist/cjs/index.js.map 2.9 kB 0.6%↑2.9 kB
dist/cjs/module-augmentation.js.map 10.4 kB 3%↑10.7 kB
dist/cjs/types.js.map 3.7 kB 1%↑3.8 kB
dist/cjs/utils.js 3.1 kB -1.07%↓3.0 kB
dist/cjs/utils.js.map 5.6 kB -0.59%↓5.6 kB
dist/esm/chakra-components/control.js 9.6 kB 3%↑9.9 kB
dist/esm/chakra-components/control.js.map 17.8 kB 3%↑18.3 kB
dist/esm/chakra-components/input.js 3.2 kB -4.75%↓3.0 kB
dist/esm/chakra-components/input.js.map 5.4 kB -4.66%↓5.1 kB
dist/esm/chakra-components/menu.js 10.9 kB 6%↑11.6 kB
dist/esm/chakra-components/menu.js.map 21.9 kB 3%↑22.5 kB
dist/esm/index.js.map 1.9 kB 0.8%↑2.0 kB
dist/esm/module-augmentation.js.map 10.4 kB 3%↑10.7 kB
dist/esm/types.js.map 3.7 kB 1%↑3.8 kB
dist/esm/utils.js 2.9 kB -1.12%↓2.9 kB
dist/esm/utils.js.map 4.7 kB -0.7%↓4.6 kB
dist/types/chakra-components/control.d.ts 1.8 kB 6%↑1.9 kB
dist/types/index.d.ts 1.2 kB 1%↑1.2 kB
dist/types/module-augmentation.d.ts 10.6 kB 3%↑10.9 kB
dist/types/types.d.ts 3.4 kB 2%↑3.5 kB
dist/types/utils.d.ts 711 B -4.64%↓678 B
Total (Includes all files) 421.4 kB 1%↑426.2 kB
Tarball size 70.4 kB 1%↑71.2 kB
Unchanged files
File Size
dist/cjs/chakra-components/containers.js 4.0 kB
dist/cjs/chakra-components/containers.js.map 8.1 kB
dist/cjs/chakra-components/index.js 2.7 kB
dist/cjs/chakra-components/index.js.map 3.8 kB
dist/cjs/chakra-components/multi-value.js 6.3 kB
dist/cjs/chakra-components/multi-value.js.map 13.1 kB
dist/cjs/chakra-components/placeholder.js 1.4 kB
dist/cjs/chakra-components/placeholder.js.map 2.8 kB
dist/cjs/chakra-components/single-value.js 1.5 kB
dist/cjs/chakra-components/single-value.js.map 3.0 kB
dist/cjs/index.js 2.0 kB
dist/cjs/module-augmentation.js 61 B
dist/cjs/select/async-creatable-select.js 2.3 kB
dist/cjs/select/async-creatable-select.js.map 3.8 kB
dist/cjs/select/async-select.js 2.2 kB
dist/cjs/select/async-select.js.map 3.6 kB
dist/cjs/select/creatable-select.js 2.3 kB
dist/cjs/select/creatable-select.js.map 3.7 kB
dist/cjs/select/select.js 2.2 kB
dist/cjs/select/select.js.map 3.5 kB
dist/cjs/types.js 47 B
dist/cjs/use-chakra-select-props.js 5.1 kB
dist/cjs/use-chakra-select-props.js.map 8.0 kB
dist/esm/chakra-components/containers.js 3.6 kB
dist/esm/chakra-components/containers.js.map 7.4 kB
dist/esm/chakra-components/index.js 1.3 kB
dist/esm/chakra-components/index.js.map 2.5 kB
dist/esm/chakra-components/multi-value.js 5.9 kB
dist/esm/chakra-components/multi-value.js.map 12.3 kB
dist/esm/chakra-components/placeholder.js 1.1 kB
dist/esm/chakra-components/placeholder.js.map 2.1 kB
dist/esm/chakra-components/single-value.js 1.2 kB
dist/esm/chakra-components/single-value.js.map 2.3 kB
dist/esm/index.js 687 B
dist/esm/module-augmentation.js 58 B
dist/esm/select/async-creatable-select.js 856 B
dist/esm/select/async-creatable-select.js.map 1.9 kB
dist/esm/select/async-select.js 800 B
dist/esm/select/async-select.js.map 1.8 kB
dist/esm/select/creatable-select.js 824 B
dist/esm/select/creatable-select.js.map 1.9 kB
dist/esm/select/select.js 768 B
dist/esm/select/select.js.map 1.7 kB
dist/esm/types.js 44 B
dist/esm/use-chakra-select-props.js 4.8 kB
dist/esm/use-chakra-select-props.js.map 7.0 kB
dist/types/chakra-components/containers.d.ts 716 B
dist/types/chakra-components/index.d.ts 5.7 kB
dist/types/chakra-components/input.d.ts 256 B
dist/types/chakra-components/menu.d.ts 1.5 kB
dist/types/chakra-components/multi-value.d.ts 1.2 kB
dist/types/chakra-components/placeholder.d.ts 280 B
dist/types/chakra-components/single-value.d.ts 280 B
dist/types/select/async-creatable-select.d.ts 572 B
dist/types/select/async-select.d.ts 508 B
dist/types/select/creatable-select.d.ts 536 B
dist/types/select/select.d.ts 436 B
dist/types/use-chakra-select-props.d.ts 574 B
LICENSE.md 1.1 kB
package.json 4.0 kB
README.md 45.9 kB

🤖 This report was automatically generated by pkg-size-action

@@ -98,7 +98,7 @@ const Control = <
data-focus-visible={isFocused ? true : undefined}
data-invalid={isInvalid ? true : undefined}
data-disabled={isDisabled ? true : undefined}
aria-readonly={isReadOnly ? true : undefined}
data-readonly={isReadOnly ? true : undefined}
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not actually an input component, and does not have an aria role for an input, so it makes more sense to use the data-readonly prop, as this is just to trigger the readonly input styles from the Charka theme

*/
export const DownChevron = (props: IconProps) => (
<Icon {...props}>
<Icon role="presentation" focusable="false" aria-hidden="true" {...props}>
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if these aria roles matter, but they're on Chakra's select component, so I decided to add them here too: https://github.com/chakra-ui/chakra-ui/blob/61f965a/packages/components/select/src/select.tsx#L168-L179

>
{children || <DownChevron sx={iconSx} />}
{children || <DownChevron sx={downChevronSx} />}
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No real changes here, just moved some types around and renamed the variables to be more consistent with the other components in the package

Comment on lines +422 to +423
paddingX: horizontalPaddingOptions[size],
paddingY: verticalPaddingOptions[size],
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After some testing in my theme branch, I realized that the single padding style was not being overridden by user defined padding values. I believe splitting them up gives less specificity, allowing the user defined styles to override them.

display: "flex",
alignItems: "center",
width: "100%",
textAlign: "start",
fontSize: size,
padding: paddings[size],
...(isFocused && menuItemStyles._focus),
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realized this would be better implemented by adding the data-focus attribute to the menu item, triggering the style in a way more in line with Chakra's theme system.

@@ -438,8 +448,9 @@ export const Option = <
)}
sx={sx}
ref={innerRef}
data-disabled={isDisabled ? true : undefined}
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realized there was no reason to use both data-disabled and aria-disabled. The data- props Chakra looks at for styling seem to be more of a fallback if the aria- props aren't applicable to be applied to a component.

| (string & {});
export type Variant = ThemeTypings["components"]["Input"]["variants"];

export type ColorScheme = ThemeTypings["colorSchemes"];
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realized I could get intellisense autocompletion for this by using Chakra's built in type for it. I also changed the other Variant types to use Chakra's built in types for these components instead of defining them manually.

@csandman csandman merged commit ecc0fe5 into main Oct 27, 2023
5 checks passed
@csandman csandman deleted the chore/cleanup branch October 27, 2023 20:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Group Heading props does not work
2 participants