Skip to content
This repository has been archived by the owner on Jul 16, 2023. It is now read-only.

Commit

Permalink
fix(components): rename collapsible to accordion to make name more me…
Browse files Browse the repository at this point in the history
…aningful
  • Loading branch information
filipowm committed Aug 1, 2020
1 parent 60e52a0 commit 892a19b
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 32 deletions.
26 changes: 13 additions & 13 deletions content/editing/rich_content/custom_components.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,46 +88,46 @@ luctus mi imperdiet lobortis vitae at urna. Sed posuere lacinia turpis a commodo
</div>
</Layout>

## Collapsible
## Accordion

Collapsible component allow hiding (collapsing) a content and revealing it on click.
You can use other components inside collapsible.
Accordion component allow hiding (collapsing) a content and revealing it on click.
You can use other components inside accordion.

**Syntax**

```html
<Collapsible title="Click here to open">
<Accordion title="Click here to open">

*Lorem ipsum* dolor **sit amet**, consectetur adipiscing elit. Aenean lobortis turpis
luctus mi imperdiet lobortis vitae at urna. Sed posuere lacinia turpis a commodo.

</Collapsible>
</Accordion>

<Collapsible title=":thumbsdown: Now is closed" titleWhenOpen=":thumbsup: Now is open" open="true">
<Accordion title=":thumbsdown: Now is closed" titleWhenOpen=":thumbsup: Now is open" open="true">

`open` define whether collapsible should be open or closed by default. Defaults to closed.

You can change title when collapsible is open by setting `titleWhenOpen` property.

</Collapsible>
</Accordion>
```

**Examples**

<Collapsible title="Click here to open">
<Accordion title="Click here to open">

*Lorem ipsum* dolor **sit amet**, consectetur adipiscing elit. Aenean lobortis turpis
luctus mi imperdiet lobortis vitae at urna. Sed posuere lacinia turpis a commodo.

</Collapsible>
</Accordion>

<Collapsible title=":thumbsdown: Now is closed" titleWhenOpen=":thumbsup: Now is open" open="true">
<Accordion title=":thumbsdown: Now is closed" titleWhenOpen=":thumbsup: Now is open" open="true">

`open` define whether collapsible should be open or closed by default. Default to closed.
`open` define whether accordion should be open or closed by default. Default to closed.

You can change title when collapsible is open by setting `titleWhenOpen` property.
You can change title when arccordion is open by setting `titleWhenOpen` property.

</Collapsible>
</Accordion>

## Highlights

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { ChevronUp, ChevronDown } from 'react-feather';
import { renderToStaticMarkup } from 'react-dom/server';
import emoji from '../../utils/emoji';

const CollapsibleWrapper = styled.div`
const AccordionWrapper = styled.div`
margin: 10px 0;
& > div {
box-shadow: 0 0 6px 0 ${(props) => props.theme.header.shadow};
Expand All @@ -20,13 +20,14 @@ margin: 10px 0;
}
}
&:hover {
border: 1px solid ${(props) => props.theme.colors.primary + 'cc'};
padding: 15px;
border: 1px solid ${(props) => props.theme.colors.primary};
}
&:after {
content: url('data:image/svg+xml; utf8, ${(props) => props.closedImg}');
float: right;
}
transition: ${(props) => props.theme.transitions.hover};
border: 1px solid transparent;
font-weight: 500;
padding: 16px;
cursor: pointer;
Expand All @@ -40,17 +41,22 @@ margin: 10px 0;
}
`;

export default ({title, titleWhenOpen, expanded, children, ...props}) => {
const theme = useTheme();
const color = encodeURIComponent(theme.colors.primary); // replace # to not follow uri as usual
const closed = renderToStaticMarkup(<ChevronDown size={22} color={color}/>)
const open = renderToStaticMarkup(<ChevronUp size={22} color={color}/>)
const triggerWhenOpen = titleWhenOpen ? titleWhenOpen : title;
return (
<CollapsibleWrapper theme={theme} openImg={open} closedImg={closed}>
<Collapsible lazyRender={true} trigger={emoji.emojify(title)} triggerWhenOpen={emoji.emojify(triggerWhenOpen)} {...props}>
{children}
</Collapsible>
</CollapsibleWrapper>
)
};
export default ({ title, titleWhenOpen, expanded, children, ...props }) => {
const theme = useTheme();
const color = encodeURIComponent(theme.colors.primary); // replace # to not follow uri as usual
const closed = renderToStaticMarkup(<ChevronDown size={22} color={color} />);
const open = renderToStaticMarkup(<ChevronUp size={22} color={color} />);
const triggerWhenOpen = titleWhenOpen ? titleWhenOpen : title;
return (
<AccordionWrapper theme={theme} openImg={open} closedImg={closed}>
<Collapsible
lazyRender={true}
trigger={emoji.emojify(title)}
triggerWhenOpen={emoji.emojify(triggerWhenOpen)}
{...props}
>
{children}
</Collapsible>
</AccordionWrapper>
);
};
4 changes: 2 additions & 2 deletions src/components/MdxComponents/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/* eslint-disable react/display-name */
import React from 'react';
import Accordion from './accordion';
import AnchorTag from './anchor';
import Badge from './badge';
import CodeBlock from './codeBlock';
import Collapsible from './collapsible';
import Highlights from './highlights';
import Icon from './icon';
import Jargon from './jargon';
Expand Down Expand Up @@ -73,7 +73,7 @@ export default {
Badge,
Layout,
Icon,
Collapsible,
Accordion,
LinkCard,
...Highlights,
};

0 comments on commit 892a19b

Please sign in to comment.