Skip to content

Commit

Permalink
feat: add label property to simple-block and implement inverse token …
Browse files Browse the repository at this point in the history
…in chip
  • Loading branch information
paulo-asilva committed Dec 4, 2024
1 parent 8872f87 commit d115575
Show file tree
Hide file tree
Showing 5 changed files with 238 additions and 223 deletions.
16 changes: 14 additions & 2 deletions src/chip.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const chipActive = style({});

export const chipVariants = styleVariants({
default: [
containerBase,
containerBase,
sprinkles({
background: vars.colors.backgroundContainer,
color: vars.colors.textPrimary,
Expand All @@ -54,6 +54,13 @@ export const chipVariants = styleVariants({
color: vars.colors.textPrimary,
}),
],
inverse: [
containerBase,
sprinkles({
background: vars.colors.brand,
color: vars.colors.textPrimaryInverse,
}),
],
active: [
chipActive,
containerBase,
Expand Down Expand Up @@ -130,6 +137,11 @@ export const iconActive = style([
{color: vars.colors.controlActivated, paddingRight: 4},
]);

export const iconInverse = style([
sprinkles({paddingRight: 4}),
{color: vars.colors.neutralLow, paddingRight: 4},
]);

export const leftPadding = styleVariants({
default: [sprinkles({paddingLeft: {mobile: 20, desktop: 12}})],
withIcon: [sprinkles({paddingLeft: {mobile: 16, desktop: 8}})],
Expand All @@ -154,4 +166,4 @@ globalStyle(`${interactive}:hover:not(${chipActive}) > ${iconActive}`, {
color: vars.colors.controlActivated,
},
},
});
});
15 changes: 10 additions & 5 deletions src/chip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,16 @@ const Chip = (props: ChipProps): JSX.Element => {
const {texts, isDarkMode, textPresets, t} = useTheme();

const overAlternative = useThemeVariant() === 'alternative';
const inverse = useThemeVariant() === 'inverse';

const body = (
<>
{Icon && (
<div className={active ? styles.iconActive : styles.icon}>
<div className={classnames({
[styles.iconActive]: active,
[styles.iconInverse]: inverse,
[styles.icon]: !active && !inverse
})}>
<Icon color="currentColor" size={pxToRem(16)} />
</div>
)}
Expand All @@ -66,7 +71,7 @@ const Chip = (props: ChipProps): JSX.Element => {
return (
<div
className={classnames(
overAlternative ? styles.chipVariants.overAlternative : styles.chipVariants.default,
inverse ? styles.chipVariants.inverse : overAlternative ? styles.chipVariants.overAlternative : styles.chipVariants.default,
styles.chipWrapper,
Icon ? styles.leftPadding.withIcon : styles.leftPadding.default,
styles.rightPadding.withIcon
Expand Down Expand Up @@ -103,7 +108,7 @@ const Chip = (props: ChipProps): JSX.Element => {
const renderContent = (dataAttributes?: DataAttributes) => (
<div
className={classnames(
styles.chipVariants[active ? 'active' : overAlternative ? 'overAlternative' : 'default'],
styles.chipVariants[active ? 'active' : inverse ? 'inverse' : overAlternative ? 'overAlternative' : 'default'],
// If the chip is wrapped inside a BaseTouchable, we set inline-flex to the Touchable instead
isTouchable ? styles.wrappedContent : styles.chipWrapper,
{
Expand All @@ -129,9 +134,9 @@ const Chip = (props: ChipProps): JSX.Element => {
{renderContent()}
</BaseTouchable>
);
}
}

return renderContent(chipDataAttributes);
};

export default Chip;
export default Chip;
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 5 additions & 3 deletions src/community/__stories__/blocks-story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,14 @@ BlockRow.args = {

type SimpleBlockArgs = {
description: string;
label: string;
};

export const BlockSimple: StoryComponent<SimpleBlockArgs> = ({description}) => {
export const BlockSimple: StoryComponent<SimpleBlockArgs> = ({description, label}) => {
return (
<ResponsiveLayout>
<Box paddingY={24} dataAttributes={{testid: 'simple-block'}}>
<SimpleBlock description={description} image={<Image height={40} src={imgExample} />} />
<SimpleBlock description={description} label={label} image={<Image height={40} src={imgExample} />} />
</Box>
</ResponsiveLayout>
);
Expand All @@ -81,6 +82,7 @@ export const BlockSimple: StoryComponent<SimpleBlockArgs> = ({description}) => {
BlockSimple.storyName = 'SimpleBlock';
BlockSimple.args = {
description: 'description',
label: 'label',
};

type InformationBlockArgs = {
Expand Down Expand Up @@ -255,4 +257,4 @@ BlockProgress.args = {
value: '20',
text: 'text',
description: 'description',
};
};
Loading

0 comments on commit d115575

Please sign in to comment.