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

fix: change inverse token chip #1309

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
97 changes: 64 additions & 33 deletions src/chip.css.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {style, styleVariants} from '@vanilla-extract/css';
import {style, styleVariants, globalStyle} from '@vanilla-extract/css';
import * as mq from './media-queries.css';
import {vars} from './skins/skin-contract.css';
import {sprinkles} from './sprinkles.css';
Expand Down Expand Up @@ -54,6 +54,16 @@ export const chipVariants = styleVariants({
color: vars.colors.textPrimary,
}),
],
inverse: [
containerBase,
sprinkles({
background: vars.colors.brandLow,
color: vars.colors.controlActivated,
}),
{
borderColor: vars.colors.controlActivated,
},
],
active: [
chipActive,
containerBase,
Expand All @@ -68,52 +78,57 @@ export const chipVariants = styleVariants({
],
});

export const interactive = style({
position: 'relative',
overflow: 'hidden',
const interactive = style({
userSelect: 'none',
cursor: 'pointer',
'@media': {
[mq.supportsHover]: {
selectors: {
[`&:hover:not(${chipActive})`]: {
color: vars.colors.textActivated,
backgroundColor: vars.colors.brandLow,
cursor: 'pointer',
},
},
},
},
});

export const button = style({
export const button = sprinkles({
border: 'none',
background: 'transparent',
padding: 0,
});

export const interactiveChipOverlay = style([
sprinkles({
left: 0,
right: 0,
top: 0,
bottom: 0,
position: 'absolute',
}),
{
backgroundColor: 'transparent',
transition: 'background-color 0.1s ease-in-out',
selectors: {
[`${interactive}:active &`]: {
backgroundColor: vars.colors.backgroundContainerPressed,
export const chipInteractiveVariants = styleVariants({
light: [
interactive,
{
'@media': {
[mq.supportsHover]: {
selectors: {
[`&:hover:not(${chipActive})`]: {
borderColor: vars.colors.brandLow,
},
},
},
},
},
'@media': {
[mq.supportsHover]: {
selectors: {
[`${interactive}:hover &`]: {
backgroundColor: vars.colors.backgroundContainerHover,
},
[`${interactive}:active &`]: {
backgroundColor: vars.colors.backgroundContainerPressed,
],
dark: [
interactive,
{
'@media': {
[mq.supportsHover]: {
selectors: {
[`&:hover:not(${chipActive})`]: {
borderColor: vars.colors.background,
},
},
},
},
[mq.touchableOnly]: {
transition: 'none',
},
},
},
]);
],
});

export const icon = style([
sprinkles({paddingRight: 4}),
Expand All @@ -134,3 +149,19 @@ export const rightPadding = styleVariants({
default: [sprinkles({paddingRight: {mobile: 20, desktop: 12}})],
withIcon: [sprinkles({paddingRight: {mobile: 16, desktop: 8}})],
});

globalStyle(`${interactive}:hover:not(${chipActive}) > ${icon}`, {
'@media': {
[mq.supportsHover]: {
color: vars.colors.controlActivated,
},
},
});

globalStyle(`${interactive}:hover:not(${chipActive}) > ${iconActive}`, {
'@media': {
[mq.supportsHover]: {
color: vars.colors.controlActivated,
},
},
});
23 changes: 17 additions & 6 deletions src/chip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,20 @@ type ChipProps = ExclusifyUnion<ClosableChipProps | ToggleChipProps | ClickableC

const Chip = (props: ChipProps): JSX.Element => {
const {Icon, children, id, dataAttributes, active, badge, onClose, closeButtonLabel} = props;
const {texts, textPresets, t} = useTheme();
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 || !!inverse,
[styles.icon]: !active && !inverse,
})}
>
<Icon color="currentColor" size={pxToRem(16)} />
</div>
)}
Expand All @@ -66,7 +72,11 @@ 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,18 +113,19 @@ 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,
{
[styles.interactive]: isInteractive,
[styles.chipInteractiveVariants[isDarkMode ? 'dark' : 'light']]: isInteractive,
},
Icon ? styles.leftPadding.withIcon : styles.leftPadding.default,
badge ? styles.rightPadding.withIcon : styles.rightPadding.default
)}
{...getPrefixedDataAttributes(dataAttributes)}
>
{isInteractive && <div className={styles.interactiveChipOverlay} />}
{body}
{renderBadge()}
</div>
Expand Down
Loading