Skip to content
Merged
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
63 changes: 42 additions & 21 deletions src/components/Expandable/Expandable.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

display: flex;
flex-direction: column;
border-top: 1px solid color(noise);

&__name {
@include text(body1);
Expand All @@ -19,26 +18,6 @@
text-overflow: ellipsis;
}

&__name--plusMinus {
&::before,
&::after {
content: '';
display: block;
position: absolute;
top: 50%;
right: 0;
transform: translateY(-50%);
height: 1px;
width: space(4);
background-color: color(ink);
}

&::before {
transform: translateY(-50%) rotate(90deg);
transition: transform 200ms;
}
}

&__icon {
height: 100%;
padding-top: space(4);
Expand Down Expand Up @@ -66,6 +45,28 @@
}
}

&--plus-minus {
#{$self}__name {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

love this, clean 👍

&::before,
&::after {
content: '';
display: block;
position: absolute;
top: 50%;
right: 0;
transform: translateY(-50%);
height: 1px;
width: space(4);
background-color: color(ink);
}

&::before {
transform: translateY(-50%) rotate(90deg);
transition: transform 200ms;
}
}
}

&--expanded {
#{$self}__name {
&::before {
Expand All @@ -77,4 +78,24 @@
display: block;
}
}

&--with-border {
border-top: 1px solid color(noise);
}

&--dark-background {
border-color: color(cement);
color: color(snow);

#{$self}__name {
&::before,
&::after {
background-color: color(snow);
}
}

#{$self}__contents {
color: color(snow);
}
}
}
12 changes: 12 additions & 0 deletions src/components/Expandable/Expandable.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,18 @@ export const ChevronIcon = () => (
</States>
);

export const DarkBackground = () => (
<div style={{ backgroundColor: 'black', padding: '20px' }}>
<Expandable name='Editor’s Note' background='dark'>
Mark Cross’ ‘Cole’ duffle bag is crafted from textured grain leather with ample space for your
long-haul travels. It opens to reveal red twill lining and ample compartments for your
essentials. It has polished silver-tone palladium hardware and is stamped with the label’s
signature foil logo along the front. Adjust the removable shoulder strap for easy navigation
through busy airport terminals.
</Expandable>
</div>
);

export const Stacked = () => (
<States>
<Stack space={0}>
Expand Down
23 changes: 15 additions & 8 deletions src/components/Expandable/Expandable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export type ExpandableProps = React.HTMLAttributes<HTMLDivElement> & {
virtual?: boolean;
'data-testid'?: string;
onToggle?: () => void;
background?: 'light' | 'dark';
border?: boolean;
};

export const Expandable: React.FC<ExpandableProps> = ({
Expand All @@ -27,6 +29,8 @@ export const Expandable: React.FC<ExpandableProps> = ({
// eslint-disable-next-line @typescript-eslint/naming-convention
expanded: __expanded__,
onToggle,
background = 'light',
border = true,
...rest
}) => {
const [expanded, setExpanded] = useState(defaultExpanded);
Expand All @@ -42,16 +46,19 @@ export const Expandable: React.FC<ExpandableProps> = ({

return (
<div
className={classNames('Expandable', { 'Expandable--expanded': expanded }, className)}
className={classNames(
'Expandable',
`Expandable--${background}-background`,
{
'Expandable--expanded': expanded,
'Expandable--with-border': border,
'Expandable--plus-minus': icon === 'plus-minus'
},
className
)}
{...rest}
>
<Clickable
className={classNames('Expandable__name', {
'Expandable__name--plusMinus': icon === 'plus-minus'
})}
onClick={handleClick}
data-testid={dataTestId}
>
<Clickable className='Expandable__name' onClick={handleClick} data-testid={dataTestId}>
{name}

{icon !== 'plus-minus' && (
Expand Down