-
Notifications
You must be signed in to change notification settings - Fork 2
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
feat: Adding start adornment to Chips #1058
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ type ToggleChipXss = Xss<"color" | "backgroundColor">; | |
type ToggleChipItemProps = { | ||
label: string; | ||
value: string; | ||
startAdornment?: ReactNode; | ||
/** | ||
* Whether the interactive element is disabled. | ||
* | ||
|
@@ -55,6 +56,7 @@ export function ToggleChipGroup(props: ToggleChipGroupProps) { | |
selected={state.value.includes(o.value)} | ||
label={o.label} | ||
disabled={o.disabled} | ||
startAdornment={o.startAdornment} | ||
xss={xss} | ||
{...tid[o.value]} | ||
/> | ||
|
@@ -75,11 +77,12 @@ interface ToggleChipProps { | |
* If a ReactNode, it's treated as a "disabled reason" that's shown in a tooltip. | ||
*/ | ||
disabled?: boolean | ReactNode; | ||
startAdornment?: ReactNode; | ||
xss?: ToggleChipXss; | ||
} | ||
|
||
function ToggleChip(props: ToggleChipProps) { | ||
const { label, value, groupState, selected: isSelected, disabled = false, xss, ...others } = props; | ||
const { label, value, groupState, selected: isSelected, disabled = false, startAdornment, xss, ...others } = props; | ||
const isDisabled = !!disabled; | ||
const ref = useRef(null); | ||
const { inputProps } = useCheckboxGroupItem({ value, "aria-label": label, isDisabled }, groupState, ref); | ||
|
@@ -109,7 +112,10 @@ function ToggleChip(props: ToggleChipProps) { | |
<VisuallyHidden> | ||
<input {...inputProps} {...focusProps} /> | ||
</VisuallyHidden> | ||
{label} | ||
<div css={Css.df.gap1.$}> | ||
{startAdornment} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @JonnCharpentier same push, I think (I.e. we do have things like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @stephenh we need There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah I see 🤔 ... that makes sense |
||
{label} | ||
</div> | ||
</label> | ||
), | ||
}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JonnCharpentier this is fine, but I was thinking maybe we could just change
text: string
totext: ReactNode
, similar to howtitle: ReactNode
.That way we could do like
text=...snippet of html...
Can we change to that instead? It seems lighter weight / more flexible than a new prop.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the Chip that could work, but for the
ToggleChipGroup
we need theoptions.label
to be a string so we can use it foraria-label
.