Repository navigation
Feat/update checkbox #819
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
Merged
Merged
Feat/update checkbox #819
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
1f2ff3d
refactor(checkbox): use native input events
comfrt1k ae2e476
feat(checkbox): indeterminate state
comfrt1k 116baad
feat(checkbox): shapes
comfrt1k 7d5701b
refactor(checkbox): appearances
comfrt1k 196077a
refactor(checkbox): appearances
comfrt1k 2bca472
refactor(checkbox): nested appearances
comfrt1k 74b7cb7
feat(checkbox): icons
comfrt1k eac9ba2
refactor(checkbox): styles topology
comfrt1k 8d7c733
refactor(checkbox): label position
comfrt1k e17e154
chore(common): update lock
comfrt1k 98b3b3d
feat(checkbox): update stories
comfrt1k 1c092f2
fix(checkbox): declare dynamic styles peer dependency
comfrt1k 1529731
fix(checkbox): preserve container inline styles
comfrt1k d8fd56d
fix(checkbox): sync uncontrolled state after form reset
comfrt1k 540ad40
fix(checkbox): keep story args consistently controlled
comfrt1k 682902b
chore(checkbox): merge updated v2 branch
comfrt1k 1bf345b
refactor(checkbox): extract logic from component
comfrt1k 63b6174
chore(hyperion): update raijin to 2.1.1
comfrt1k 7456d58
fix(checkbox): reset hidden input margin
comfrt1k 222013d
chore(common): format
comfrt1k 8dd9b5b
fix(checkbox): handle reset after form reassociation
comfrt1k 60313f7
chore(common): raijin version
comfrt1k 228aa81
refactor(checkbox): check shapes
comfrt1k 24b1e26
refactor(checkbox): rename files
comfrt1k 3974a58
fix(checkbox): hide area for check div
comfrt1k 6a19d47
fix(checkbox): uncontrolled checkboxes in stories
comfrt1k c678c27
fix(checkbox): indeterminate state sync
comfrt1k File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,2 @@ | ||
| export type * from './box.interfaces.js' | ||
| export * from './styles/index.js' | ||
| export * from './styles/index.js' | ||
| export type { BoxShape } from './styles/shape/interfaces.js' |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| export interface BoxAppearance { | ||
| backgroundColor: string | ||
| borderColor: string | ||
| shadow: string | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| import { createThemeContract } from '@vanilla-extract/css' | ||
| import { style } from '@vanilla-extract/css' | ||
|
|
||
| import { hiddenInputStyles } from '../../../hidden-input/index.js' | ||
|
|
||
| export const boxAppearanceVariables = createThemeContract({ | ||
| default: { | ||
| backgroundColor: null, | ||
| borderColor: null, | ||
| shadow: null, | ||
| }, | ||
| hover: { | ||
| backgroundColor: null, | ||
| borderColor: null, | ||
| shadow: null, | ||
| }, | ||
| disabled: { | ||
| backgroundColor: null, | ||
| borderColor: null, | ||
| shadow: null, | ||
| }, | ||
| focused: { | ||
| backgroundColor: null, | ||
| borderColor: null, | ||
| shadow: null, | ||
| }, | ||
| }) | ||
|
|
||
| export const boxAppearanceStyles = style({ | ||
| backgroundColor: boxAppearanceVariables.default.backgroundColor, | ||
| borderColor: boxAppearanceVariables.default.borderColor, | ||
| boxShadow: boxAppearanceVariables.default.shadow, | ||
| selectors: { | ||
| [`${hiddenInputStyles}:hover:not(:disabled) + &`]: { | ||
| backgroundColor: boxAppearanceVariables.hover.backgroundColor, | ||
| borderColor: boxAppearanceVariables.hover.borderColor, | ||
| boxShadow: boxAppearanceVariables.hover.shadow, | ||
| }, | ||
| [`${hiddenInputStyles}:focus-visible:not(:disabled) + &`]: { | ||
| backgroundColor: boxAppearanceVariables.focused.backgroundColor, | ||
| borderColor: boxAppearanceVariables.focused.borderColor, | ||
| boxShadow: boxAppearanceVariables.focused.shadow, | ||
| }, | ||
| [`${hiddenInputStyles}:disabled + &`]: { | ||
| backgroundColor: boxAppearanceVariables.disabled.backgroundColor, | ||
| borderColor: boxAppearanceVariables.disabled.borderColor, | ||
| boxShadow: boxAppearanceVariables.disabled.shadow, | ||
| }, | ||
| }, | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| export * from './appearance.css.js' | ||
| export * from './base.css.js' | ||
| export * from './shape.css.js' | ||
| export * from './appearance/styles.css.js' | ||
| export type * from './appearance/interfaces.js' | ||
| export * from './base.css.js' | ||
| export * from './shape/variants.css.js' |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import type { CSSProperties } from 'react' | ||
|
|
||
| export interface BoxShape { | ||
| className: string | ||
| elevationSize: 'md' | 'sm' | 'xs' | ||
| padding?: CSSProperties['padding'] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| import type { BoxShape } from './interfaces.js' | ||
|
|
||
| import { style } from '@vanilla-extract/css' | ||
|
|
||
| import { spacing } from '@atls-ui/theme' | ||
| import { borderWidths } from '@atls-ui/theme/tokens' | ||
| import { radii } from '@atls-ui/theme/tokens' | ||
|
|
||
| export const boxShapeStyles: Record<'lg' | 'md' | 'sm', BoxShape> = { | ||
| sm: { | ||
| className: style({ | ||
| width: '18px', | ||
| height: '18px', | ||
| borderRadius: radii.xs2, | ||
| borderWidth: borderWidths.sm, | ||
| }), | ||
| elevationSize: 'xs', | ||
| padding: spacing.component.none, | ||
| }, | ||
| md: { | ||
| className: style({ | ||
| width: '24px', | ||
| height: '24px', | ||
| borderRadius: radii.xs2, | ||
| borderWidth: borderWidths.sm, | ||
| }), | ||
| elevationSize: 'sm', | ||
| padding: spacing.component.none, | ||
| }, | ||
| lg: { | ||
| className: style({ | ||
| width: '28px', | ||
| height: '28px', | ||
| borderRadius: radii.xs2, | ||
| borderWidth: borderWidths.sm, | ||
| }), | ||
| elevationSize: 'md', | ||
| padding: spacing.component.none, | ||
| }, | ||
| } |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| export interface CheckAppearance { | ||
| color: string | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| import { createThemeContract } from '@vanilla-extract/css' | ||
| import { style } from '@vanilla-extract/css' | ||
|
|
||
| import { boxBaseStyles } from '../../box/styles/base.css.js' | ||
| import { hiddenInputStyles } from '../../hidden-input/index.js' | ||
|
|
||
| export const checkAppearanceVariables = createThemeContract({ | ||
| default: { | ||
| color: null, | ||
| }, | ||
| hover: { | ||
| color: null, | ||
| }, | ||
| disabled: { | ||
| color: null, | ||
| }, | ||
| focused: { | ||
| color: null, | ||
| }, | ||
| }) | ||
|
|
||
| export const checkAppearanceStyles = style({ | ||
| color: checkAppearanceVariables.default.color, | ||
| selectors: { | ||
| [`${hiddenInputStyles}:hover:not(:disabled) + ${boxBaseStyles} &`]: { | ||
| color: checkAppearanceVariables.hover.color, | ||
| }, | ||
| [`${hiddenInputStyles}:focus-visible:not(:disabled) + ${boxBaseStyles} &`]: { | ||
| color: checkAppearanceVariables.focused.color, | ||
| }, | ||
| [`${hiddenInputStyles}:disabled + ${boxBaseStyles} &`]: { | ||
| color: checkAppearanceVariables.disabled.color, | ||
| }, | ||
| }, | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import { style } from '@vanilla-extract/css' | ||
|
|
||
| export const checkBaseStyles = style({ | ||
| display: 'flex', | ||
| alignItems: 'center', | ||
| justifyContent: 'center', | ||
| visibility: 'hidden', | ||
| width: '100%', | ||
| height: '100%', | ||
| lineHeight: 1, | ||
| }) | ||
|
|
||
| export const checkVisibleStyles = style({ | ||
| visibility: 'visible', | ||
| }) |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| import type { ReactNode } from 'react' | ||
|
|
||
| import type { CheckProps } from './interfaces.js' | ||
|
|
||
| import { assignInlineVars } from '@vanilla-extract/dynamic' | ||
| import { clsx } from 'clsx' | ||
|
|
||
| import { CheckIcon } from '@atls-ui-parts/icons' | ||
| import { MinusIcon } from '@atls-ui-parts/icons' | ||
|
|
||
| import { checkAppearanceStyles } from './appearance/styles.css.js' | ||
| import { checkAppearanceVariables } from './appearance/styles.css.js' | ||
| import { checkBaseStyles } from './base.css.js' | ||
| import { checkVisibleStyles } from './base.css.js' | ||
|
|
||
| export const Check = ({ | ||
| appearance, | ||
| checked, | ||
| checkedIcon, | ||
| className, | ||
| indeterminate, | ||
| indeterminateIcon, | ||
| shape, | ||
| }: CheckProps): ReactNode => { | ||
| let icon = checkedIcon ?? <CheckIcon /> | ||
|
|
||
| if (indeterminate) { | ||
| icon = indeterminateIcon ?? <MinusIcon /> | ||
| } | ||
|
|
||
| return ( | ||
| <div | ||
| style={assignInlineVars(checkAppearanceVariables, appearance)} | ||
| className={clsx( | ||
| checkBaseStyles, | ||
| checkAppearanceStyles, | ||
| shape, | ||
| (checked || indeterminate) && checkVisibleStyles, | ||
| className | ||
| )} | ||
| > | ||
| {icon} | ||
| </div> | ||
| ) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,4 @@ | ||
| export * from './appearance.css.js' | ||
| export * from './check.css.js' | ||
| export * from './base.css.js' | ||
| export * from './shape.css.js' | ||
| export * from './appearance/styles.css.js' | ||
| export type * from './appearance/interfaces.js' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import type { ReactNode } from 'react' | ||
|
|
||
| import type { CheckboxAppearanceStates } from '../styles/appearance/interfaces.js' | ||
|
|
||
| export interface CheckProps { | ||
| appearance: CheckboxAppearanceStates['check'] | ||
| checked: boolean | ||
| checkedIcon?: ReactNode | ||
| className?: string | ||
| indeterminate?: boolean | ||
| indeterminateIcon?: ReactNode | ||
| shape: string | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| import { globalStyle } from '@vanilla-extract/css' | ||
| import { style } from '@vanilla-extract/css' | ||
|
|
||
| const checkSmallShapeStyles = style({ | ||
| fontSize: '12px', | ||
| }) | ||
|
|
||
| const checkMediumShapeStyles = style({ | ||
| fontSize: '14px', | ||
| }) | ||
|
|
||
| const checkLargeShapeStyles = style({ | ||
| fontSize: '18px', | ||
| }) | ||
|
|
||
| globalStyle(`${checkSmallShapeStyles} > svg`, { | ||
| width: '12px', | ||
| height: '12px', | ||
| }) | ||
|
|
||
| globalStyle(`${checkMediumShapeStyles} > svg`, { | ||
| width: '14px', | ||
| height: '14px', | ||
| }) | ||
|
|
||
| globalStyle(`${checkLargeShapeStyles} > svg`, { | ||
| width: '18px', | ||
| height: '18px', | ||
| }) | ||
|
|
||
| export const checkShapeStyles = { | ||
| sm: checkSmallShapeStyles, | ||
| md: checkMediumShapeStyles, | ||
| lg: checkLargeShapeStyles, | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.