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

Commit

Permalink
Refactor RoxButton into separate components RowButtons and `RowBu…
Browse files Browse the repository at this point in the history
…tton`.

DDFFORM-3
  • Loading branch information
kasperbirch1 committed Nov 23, 2023
1 parent 15cdaf9 commit 14bd2fa
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 41 deletions.
1 change: 1 addition & 0 deletions base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
@import "./src/stories/Library/button-box/button-box";
@import "./src/stories/Library/links/arrow-link/arrow-link";
@import "./src/stories/Library/Buttons/row-button/row-button";
@import "./src/stories/Library/Buttons/row-button/row-buttons";
@import "./src/stories/Library/article-header/article-header";

// Autosuggest block styling needs to be loaded before the rest of the scss for autosuggest
Expand Down
14 changes: 2 additions & 12 deletions src/stories/Library/Buttons/row-button/RowButton.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ export default {
component: RowButton,
decorators: [withDesign],
argTypes: {
labels: {
defaultValue: ["Netmedier"],
label: {
defaultValue: "Netmedier",
},
},
parameters: {
Expand All @@ -25,13 +25,3 @@ const Template: ComponentStory<typeof RowButton> = (args) => (
);

export const Default = Template.bind({});

export const TwoButtons = Template.bind({});
TwoButtons.args = {
labels: ["Netmedier", "Licenser"],
};

export const ThreeAndMoreButtons = Template.bind({});
ThreeAndMoreButtons.args = {
labels: ["Netmedier", "Licenser", "This is hiddden"],
};
30 changes: 8 additions & 22 deletions src/stories/Library/Buttons/row-button/RowButton.tsx
Original file line number Diff line number Diff line change
@@ -1,30 +1,16 @@
import clsx from "clsx";
import { FC } from "react";

type RowButtonProps = {
labels: string[];
className?: string;
label: string;
};

const RowButton: FC<RowButtonProps> = ({ labels, className }) => (
<div className={clsx("row-buttons", className)}>
{labels.slice(0, 2).map((label) => (
<button
className="row-button text-tags row-button__text capitalize-all"
type="button"
>
{label}
</button>
))}
{labels.length > 2 && (
<button
className="row-button text-tags row-button__text capitalize-all"
type="button"
>
...
</button>
)}
</div>
const RowButton: FC<RowButtonProps> = ({ label }) => (
<button
className="row-button text-tags row-button__text capitalize-all"
type="button"
>
{label}
</button>
);

export default RowButton;
35 changes: 35 additions & 0 deletions src/stories/Library/Buttons/row-button/RowButtons.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { ComponentStory, ComponentMeta } from "@storybook/react";
import { withDesign } from "storybook-addon-designs";
import RowButtons from "./RowButtons";

export default {
title: "Library / Buttons / RowButtons",
component: RowButtons,
decorators: [withDesign],
argTypes: {
labels: {
defaultValue: ["Netmedier"],
},
},
parameters: {
design: {
type: "figma",
url: "https://www.figma.com/file/Zx9GrkFA3l4ISvyZD2q0Qi/Designsystem?type=design&node-id=7880%3A59070&mode=dev",
},
layout: "centered",
},
} as ComponentMeta<typeof RowButtons>;

const Template: ComponentStory<typeof RowButtons> = (args) => (
<RowButtons {...args} />
);

export const TwoButtons = Template.bind({});
TwoButtons.args = {
labels: ["Netmedier", "Licenser"],
};

export const ThreeAndMoreButtons = Template.bind({});
ThreeAndMoreButtons.args = {
labels: ["Netmedier", "Licenser", "This is hiddden"],
};
19 changes: 19 additions & 0 deletions src/stories/Library/Buttons/row-button/RowButtons.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import clsx from "clsx";
import { FC } from "react";
import RowButton from "./RowButton";

type RowButtonProps = {
labels: string[];
className?: string;
};

const RowButtons: FC<RowButtonProps> = ({ labels, className }) => (
<div className={clsx("row-buttons", className)}>
{labels.slice(0, 2).map((label) => (
<RowButton label={label} />
))}
{labels.length > 2 && <RowButton label="..." />}
</div>
);

export default RowButtons;
5 changes: 0 additions & 5 deletions src/stories/Library/Buttons/row-button/row-button.scss
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
.row-buttons {
display: flex;
flex-direction: row;
}

.row-button {
height: 40px;
background-color: $c-global-secondary;
Expand Down
4 changes: 4 additions & 0 deletions src/stories/Library/Buttons/row-button/row-buttons.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.row-buttons {
display: flex;
flex-direction: row;
}
4 changes: 2 additions & 2 deletions src/stories/Library/article-header/ArticleHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { FC } from "react";
import RowButton from "../Buttons/row-button/RowButton";
import RowButtons from "../Buttons/row-button/RowButtons";
import ArrowLink from "../links/arrow-link/ArrowLink";

type ArticleHeaderProps = {
Expand Down Expand Up @@ -29,7 +29,7 @@ const ArticleHeader: FC<ArticleHeaderProps> = ({
</a>
<span className="article-header__date">{date}</span>
</p>
<RowButton labels={["Netmedier", "Licenser", "This is hiddden"]} />
<RowButtons labels={["Netmedier", "Licenser", "This is hiddden"]} />
</header>
);
};
Expand Down

0 comments on commit 14bd2fa

Please sign in to comment.