Skip to content

Commit f3bb900

Browse files
author
Sine Jespersen
committed
Merge branch 'develop' into feature/menu-update
2 parents 0081c2d + 59ac58f commit f3bb900

File tree

17 files changed

+163
-62
lines changed

17 files changed

+163
-62
lines changed

src/stories/Blocks/footer/Footer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Pagefold } from "../../Library/pagefold/Pagefold";
1+
import Pagefold from "../../Library/pagefold/Pagefold";
22
import { Accordion } from "../../Library/accordion/Accordion";
33
import { Dropdown } from "../../Library/dropdown/Dropdown";
44
import { Logo } from "../../Library/logo/Logo";

src/stories/Blocks/header/Header.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { useEffect } from "react";
2-
32
import { Logo } from "../../Library/logo/Logo";
4-
import { Pagefold } from "../../Library/pagefold/Pagefold";
3+
import Pagefold from "../../Library/pagefold/Pagefold";
54

65
export type HeaderProps = {
76
signedIn: boolean;

src/stories/Library/Buttons/button/Button.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
import clsx from "clsx";
22
import { ButtonIcon } from "./ButtonIcon";
3-
import {
4-
ButtonSize,
5-
ButtonType,
6-
ButtonVariant,
7-
getSize,
8-
getVariant,
9-
} from "./helper";
3+
import { getSize, getVariant } from "./helper";
4+
import { ButtonSize, ButtonType, ButtonVariant } from "./types";
105

116
export type ButtonProps = {
127
label: string;

src/stories/Library/Buttons/button/ButtonIcon.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ReactComponent as ArrowSmallRight } from "../../Arrows/icon-arrow-ui/icon-arrow-ui-small-right.svg";
22
import { IconExternalLink } from "../../Icons/icon-external-link/IconExternalLink";
3-
import { ButtonType } from "./helper";
3+
import { ButtonType } from "./types";
44

55
export interface ButtonIconProps {
66
buttonType?: ButtonType;

src/stories/Library/Buttons/button/LinkButton.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
import clsx from "clsx";
22
import { ButtonIcon } from "./ButtonIcon";
3-
import {
4-
ButtonSize,
5-
ButtonType,
6-
ButtonVariant,
7-
getSize,
8-
getVariant,
9-
} from "./helper";
3+
import { getSize, getVariant } from "./helper";
4+
import { ButtonSize, ButtonType, ButtonVariant } from "./types";
105

116
export type LinkButtonProps = {
127
href: string;
Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
export type ButtonType = "none" | "default" | "external-link" | "search";
2-
export type ButtonVariant = "outline" | "filled";
3-
export type ButtonSize = "xsmall" | "small" | "medium" | "large" | "xlarge";
1+
import clsx from "clsx";
2+
import { PageFoldType } from "../../pagefold/types";
3+
import { ButtonSize, ButtonVariant } from "./types";
44

5-
export const getSize = (size: ButtonSize) => {
5+
export const getSize = (size: ButtonSize): string => {
66
if (size === "xlarge") return "btn-xlarge";
77
if (size === "large") return "btn-large";
88
if (size === "medium") return "btn-medium";
@@ -11,8 +11,29 @@ export const getSize = (size: ButtonSize) => {
1111
return "";
1212
};
1313

14-
export const getVariant = (variant: ButtonVariant) => {
14+
export const getVariant = (variant: ButtonVariant): string => {
1515
if (variant === "filled") return "btn-filled";
1616
if (variant === "outline") return "btn-outline";
1717
return "";
1818
};
19+
20+
export const getPagefoldClasses = ({
21+
isInheriting,
22+
isAContainer,
23+
size,
24+
type,
25+
className,
26+
}: PageFoldType): { wrapper: string; triangle: string } => {
27+
return {
28+
wrapper: clsx(
29+
`pagefold-parent--${size}`,
30+
{ "internal-pagefold-parent": isAContainer },
31+
className
32+
),
33+
triangle: clsx(
34+
`pagefold-triangle--${size}`,
35+
{ [`pagefold-triangle--${type}`]: type },
36+
{ "pagefold-inherit-parent": isInheriting }
37+
),
38+
};
39+
};
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export type ButtonType = "none" | "default" | "external-link" | "search";
2+
export type ButtonVariant = "outline" | "filled";
3+
export type ButtonSize =
4+
| "none"
5+
| "xsmall"
6+
| "small"
7+
| "medium"
8+
| "large"
9+
| "xlarge";
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { PageFoldType } from "../../pagefold/types";
2+
import { getPagefoldClasses } from "../button/helper";
3+
4+
type PageFoldButtonProps = PageFoldType & {
5+
children?: React.ReactNode;
6+
};
7+
8+
const PageFoldButton = ({
9+
isInheriting,
10+
isAContainer,
11+
size,
12+
type,
13+
children,
14+
className,
15+
status,
16+
}: PageFoldButtonProps) => {
17+
const classes = getPagefoldClasses({
18+
isInheriting,
19+
isAContainer,
20+
size,
21+
type,
22+
className,
23+
});
24+
25+
return (
26+
<button
27+
type="button"
28+
aria-pressed={status === "selected"}
29+
className={classes.wrapper}
30+
>
31+
<div className={classes.triangle} />
32+
{children}
33+
</button>
34+
);
35+
};
36+
37+
export default PageFoldButton;

src/stories/Library/availability-label/AvailabilityLabel.stories.tsx

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,25 @@ export default {
1111
manifestationType: {
1212
name: "Manifestation Type",
1313
options: ["Bog", "Ebog", "Lydbog (net)", "Lydbog (cd-mp3)", undefined],
14-
control: { disable: true },
14+
control: "radio",
1515
},
1616
availability: {
1717
name: "Availability",
1818
options: ["Hjemme", "Online", "Udlånt"],
19-
control: { disable: true },
19+
control: "radio",
2020
},
2121
status: {
2222
name: "Status",
2323
options: ["available", "unavailable", "selected"],
24-
control: { disable: true },
24+
control: "radio",
25+
},
26+
quantity: {
27+
name: "Quantity",
28+
control: "number",
29+
},
30+
button: {
31+
name: "Button",
32+
control: "boolean",
2533
},
2634
},
2735
parameters: {},
@@ -36,20 +44,23 @@ Available.args = {
3644
manifestationType: "Bog",
3745
availability: "Hjemme",
3846
status: "available",
47+
button: false,
3948
};
4049

4150
export const Selected = Template.bind({});
4251
Selected.args = {
4352
manifestationType: "Ebog",
4453
availability: "Online",
4554
status: "selected",
55+
button: false,
4656
};
4757

4858
export const Unavailable = Template.bind({});
4959
Unavailable.args = {
5060
manifestationType: "Lydbog (cd-mp3)",
5161
availability: "Udlånt",
5262
status: "unavailable",
63+
button: false,
5364
};
5465

5566
export const WithoutManifestationType = Template.bind({});
@@ -58,4 +69,13 @@ WithoutManifestationType.args = {
5869
manifestationType: undefined,
5970
availability: "Udlånt",
6071
status: "unavailable",
72+
button: false,
73+
};
74+
75+
export const PageFoldButton = Template.bind({});
76+
PageFoldButton.args = {
77+
manifestationType: "Bog",
78+
availability: "Hjemme",
79+
status: "available",
80+
button: true,
6181
};

src/stories/Library/availability-label/AvailabilityLabel.tsx

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
import { AvailabilityLabelPropsType } from "../../availability-label/types";
2-
import { Pagefold } from "../pagefold/Pagefold";
2+
import PageFoldButton from "../Buttons/page-fold-button/PageFoldButton";
3+
import Pagefold from "../pagefold/Pagefold";
34
import { withAvailabilityProps } from "./abilityLabel.hoc";
45

56
const AvailabilityLabel: React.FC<AvailabilityLabelPropsType> = ({
67
manifestationType,
78
availability,
89
status,
910
quantity,
11+
button,
1012
}) => {
11-
const AvailabilityPagefold = withAvailabilityProps(Pagefold);
12-
13-
return (
14-
<AvailabilityPagefold status={status}>
13+
const content = (
14+
<>
1515
<img
1616
className={`availability-label__check ${status}`}
1717
src="icons/collection/Check.svg"
18-
alt="check-icon"
18+
alt=""
1919
/>
2020
{manifestationType && (
2121
<>
@@ -39,8 +39,21 @@ const AvailabilityLabel: React.FC<AvailabilityLabelPropsType> = ({
3939
</p>
4040
</>
4141
)}
42-
</AvailabilityPagefold>
42+
</>
4343
);
44+
45+
const AvailabilityPagefold = withAvailabilityProps(Pagefold);
46+
const AvailabilityPagefoldButton = withAvailabilityProps(PageFoldButton);
47+
48+
if (button) {
49+
return (
50+
<AvailabilityPagefoldButton status={status}>
51+
{content}
52+
</AvailabilityPagefoldButton>
53+
);
54+
}
55+
56+
return <AvailabilityPagefold status={status}>{content}</AvailabilityPagefold>;
4457
};
4558

4659
export default AvailabilityLabel;

0 commit comments

Comments
 (0)