Update accordion styling

This commit is contained in:
Gert Hengeveld 2025-03-05 09:20:14 +01:00
parent 5a2b90dfa4
commit f2d8eb0eaa
2 changed files with 27 additions and 36 deletions

View File

@ -1,22 +1,18 @@
import type { FC } from 'react'; import type { FC } from 'react';
import React from 'react'; import React from 'react';
import { Link } from 'storybook/internal/components';
import { styled } from 'storybook/internal/theming'; import { styled } from 'storybook/internal/theming';
import type { Result } from 'axe-core'; import type { Result } from 'axe-core';
const Wrapper = styled.div({ const Wrapper = styled.div({
padding: 12, padding: '0 15px',
marginBottom: 10, marginBottom: 10,
}); });
const Description = styled.p({ const Description = styled.p({
margin: '0 0 12px', margin: '0 0 10px',
});
const Link = styled.a({
marginTop: 12,
textDecoration: 'underline',
color: 'inherit',
display: 'block',
}); });
interface InfoProps { interface InfoProps {
@ -26,9 +22,11 @@ interface InfoProps {
export const Info: FC<InfoProps> = ({ item }) => { export const Info: FC<InfoProps> = ({ item }) => {
return ( return (
<Wrapper> <Wrapper>
<Description>{item.description}</Description> <Description>
<Link href={item.helpUrl} target="_blank"> {item.description.endsWith('.') ? item.description : `${item.description}.`}
More info... </Description>
<Link href={item.helpUrl} target="_blank" withArrow>
Learn how to resolve this violation
</Link> </Link>
</Wrapper> </Wrapper>
); );

View File

@ -1,5 +1,6 @@
import React, { Fragment, useState } from 'react'; import React, { Fragment, useState } from 'react';
import { IconButton } from 'storybook/internal/components';
import { styled } from 'storybook/internal/theming'; import { styled } from 'storybook/internal/theming';
import { ChevronSmallDownIcon } from '@storybook/icons'; import { ChevronSmallDownIcon } from '@storybook/icons';
@ -13,33 +14,29 @@ import { Tags } from './Tags';
const Wrapper = styled.div(({ theme }) => ({ const Wrapper = styled.div(({ theme }) => ({
display: 'flex', display: 'flex',
flexDirection: 'column',
width: '100%', width: '100%',
borderBottom: `1px solid ${theme.appBorderColor}`, borderBottom: `1px solid ${theme.appBorderColor}`,
'&:hover': {
background: theme.background.hoverable,
},
})); }));
const Icon = styled(ChevronSmallDownIcon)({ const Icon = styled(ChevronSmallDownIcon)({
marginRight: 10,
transition: 'transform 0.1s ease-in-out', transition: 'transform 0.1s ease-in-out',
verticalAlign: 'inherit',
}); });
const HeaderBar = styled.div(({ theme }) => ({ const HeaderBar = styled.div(({ theme }) => ({
padding: theme.layoutMargin, display: 'flex',
paddingLeft: theme.layoutMargin - 3, justifyContent: 'space-between',
lineHeight: '20px', alignItems: 'center',
padding: 5,
paddingLeft: 15,
minHeight: 40,
background: 'none', background: 'none',
color: 'inherit', color: 'inherit',
textAlign: 'left', textAlign: 'left',
cursor: 'pointer', cursor: 'pointer',
borderLeft: '3px solid transparent',
width: '100%', width: '100%',
'&:hover': {
'&:focus': { color: theme.color.secondary,
outline: '0 none',
borderLeft: `3px solid ${theme.color.secondary}`,
}, },
})); }));
@ -55,17 +52,13 @@ export const Item = (props: ItemProps) => {
const { item, type } = props; const { item, type } = props;
return ( return (
<Fragment> <Wrapper>
<Wrapper> <HeaderBar onClick={() => onToggle(!open)} role="button">
<HeaderBar onClick={() => onToggle(!open)} role="button"> <strong>{item.help}</strong>
<Icon <IconButton onClick={() => onToggle(!open)}>
style={{ <Icon style={{ transform: `rotate(${open ? -180 : 0}deg)` }} />
transform: `rotate(${open ? 0 : -90}deg)`, </IconButton>
}} </HeaderBar>
/>
{item.help}
</HeaderBar>
</Wrapper>
{open ? ( {open ? (
<Fragment> <Fragment>
<Info item={item} key="info" /> <Info item={item} key="info" />
@ -73,6 +66,6 @@ export const Item = (props: ItemProps) => {
<Tags tags={item.tags} key="tags" /> <Tags tags={item.tags} key="tags" />
</Fragment> </Fragment>
) : null} ) : null}
</Fragment> </Wrapper>
); );
}; };