Skip to content

Commit bdb329a

Browse files
authored
Merge pull request danskernesdigitalebibliotek#86 from reload/feature/disclosure
feature/disclosure
2 parents ecd6261 + 6028e43 commit bdb329a

File tree

5 files changed

+125
-0
lines changed

5 files changed

+125
-0
lines changed

base.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
@import "./src/stories/Library/reservation-header/reservation-header";
6262
@import "./src/stories/Library/material-header/material-periodikum-select";
6363
@import "./src/stories/Library/material-description/material-description";
64+
@import "./src/stories/Library/disclosure/disclosure";
6465
@import "./src/stories/Library/horizontal-term-line/horizontal-term-line";
6566
@import "./src/stories/Library/search-result-page/search-result-info";
6667
@import "./src/stories/Library/search-result-page/search-result-page";
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { ComponentMeta, ComponentStory } from "@storybook/react";
2+
import { withDesign } from "storybook-addon-designs";
3+
import { Disclosure, DisclosureProps } from "./Disclosure";
4+
5+
export default {
6+
title: "Library / Disclosure",
7+
component: Disclosure,
8+
decorators: [withDesign],
9+
argTypes: {
10+
headline: {
11+
name: "Headline",
12+
defaultValue: "Headline",
13+
control: { type: "text" },
14+
},
15+
children: {
16+
name: "Headline",
17+
defaultValue: "I am the content. Look at me!",
18+
control: { type: "text" },
19+
},
20+
icon: {
21+
name: "Icon name",
22+
defaultValue: "Various",
23+
options: ["Various", "Receipt", "Create", "Profile"],
24+
control: { type: "select" },
25+
},
26+
},
27+
parameters: {
28+
design: {
29+
type: "figma",
30+
url: "https://www.figma.com/file/ETOZIfmgGS1HUfio57SOh7/S%C3%B8gning?node-id=416%3A15008",
31+
},
32+
},
33+
} as ComponentMeta<typeof Disclosure>;
34+
35+
const Template: ComponentStory<typeof Disclosure> = (args: DisclosureProps) => (
36+
<Disclosure {...args} />
37+
);
38+
39+
export const Default = Template.bind({});
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { useState } from "react";
2+
3+
export type DisclosureProps = {
4+
headline: string;
5+
children: React.ReactNode | string;
6+
icon: "Various" | "Receipt" | "Create" | "Profile";
7+
};
8+
9+
export const Disclosure: React.FC<DisclosureProps> = ({
10+
headline,
11+
children,
12+
icon,
13+
}) => {
14+
const [isOpen, setIsOpen] = useState(false);
15+
return (
16+
<details className="disclosure text-body-large">
17+
<summary
18+
className="disclosure__headline text-body-large"
19+
onClick={() => {
20+
setIsOpen(!isOpen);
21+
}}
22+
>
23+
<div className="disclosure__icon bg-identity-tint-120 m-24">
24+
<img
25+
className="disclosure__icon"
26+
src={`icons/collection/${icon}.svg`}
27+
alt="various-icon"
28+
/>
29+
</div>
30+
{headline}
31+
<img
32+
className={`disclosure__expand mr-24 noselect ${
33+
isOpen ? "disclosure__expand-open" : ""
34+
}`}
35+
src="icons/collection/ExpandMore.svg"
36+
alt="various-icon"
37+
/>
38+
</summary>
39+
{children}
40+
</details>
41+
);
42+
};
43+
44+
export default Disclosure;
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
.disclosure {
2+
width: auto;
3+
border: solid 1px $c-global-tertiary-1;
4+
5+
@include breakpoint-m {
6+
margin: 0 133px;
7+
}
8+
9+
&__headline {
10+
display: flex;
11+
align-items: center;
12+
justify-content: baseline;
13+
cursor: pointer;
14+
}
15+
16+
&__icon {
17+
height: 40px;
18+
width: 40px;
19+
border-radius: 20px;
20+
display: flex;
21+
justify-content: center;
22+
23+
& > img {
24+
width: 24px;
25+
filter: invert(1);
26+
}
27+
}
28+
29+
&__expand {
30+
margin-left: auto;
31+
&-open {
32+
transform: scaleY(-1);
33+
}
34+
}
35+
}

src/styles/scss/shared.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,9 @@
100100
justify-content: flex-end;
101101
padding: 20px;
102102
}
103+
104+
.noselect {
105+
-webkit-user-select: none; /* Safari */
106+
-ms-user-select: none; /* IE 10 and IE 11 */
107+
user-select: none; /* Standard syntax */
108+
}

0 commit comments

Comments
 (0)