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

Commit

Permalink
Fix alignment in horizontal-term-line & separate ButtonExpand
Browse files Browse the repository at this point in the history
Fix alignment in `horizontal-term-line` & separate `ButtonExpand`
- Correct alignment issues for horizontal-term-line
- Remove unused `.horizontal-term-line__list` class
- Extract `button.horizontal-term-line__expand` into separate `ButtonExpand` component for reusability
  • Loading branch information
kasperbirch1 committed Apr 18, 2023
1 parent 17f35cb commit b2ea9e9
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 30 deletions.
1 change: 1 addition & 0 deletions base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
@import "./src/stories/Library/Icons/icon-favourite/icon-favourite";
@import "./src/stories/Library/Buttons/button-favourite/button-favourite";
@import "./src/stories/Library/Buttons/icon-button/icon-button";
@import "./src/stories/Library/Buttons/button/button-expand/button-expand";
@import "./src/stories/Library/warning-status/warning-status";
@import "./src/stories/Library/availability-label/availability-label";
@import "./src/stories/Library/avatar/avatar";
Expand Down
28 changes: 28 additions & 0 deletions src/stories/Library/Buttons/button/button-expand/ButtonExpand.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import clsx from "clsx";
import { FC } from "react";

export type ButtonExpandProps = {
showMore: boolean;
setShowMore: (showMore: boolean) => void;
};

const ButtonExpand: FC<ButtonExpandProps> = ({ showMore, setShowMore }) => {
return (
<button
className="button-expand"
type="button"
onClick={() => setShowMore(!showMore)}
aria-label="Expand More"
>
<img
className={clsx("button-expand__image", {
"button-expand__image--expanded": showMore,
})}
src="icons/collection/ExpandMore.svg"
alt=""
/>
</button>
);
};

export default ButtonExpand;
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.button-expand {
cursor: pointer;
align-self: center;

&__image {
transition: transform 0.3s ease-in-out;

&.button-expand__image--expanded {
transform: scaleY(-1);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { ComponentStory, ComponentMeta } from "@storybook/react";
import ButtonExpand, { ButtonExpandProps } from "./ButtonExpand";

export default {
title: "Library / Buttons / Button Expand",
component: ButtonExpand,
parameters: {},
argTypes: {
showMore: {
control: {
type: "boolean",
},
title: {
control: {
type: "text",
},
},
},
},
} as ComponentMeta<typeof ButtonExpand>;

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

export const Default = Template.bind({});
Default.args = {
showMore: false,
};

export const Expand = Template.bind({});
Expand.args = {
showMore: true,
};
16 changes: 2 additions & 14 deletions src/stories/Library/horizontal-term-line/HorizontalTermLine.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import clsx from "clsx";
import { useState } from "react";
import ButtonExpand from "../Buttons/button/button-expand/ButtonExpand";

export interface HorizontalTermLineList {
url: string;
Expand Down Expand Up @@ -45,19 +45,7 @@ const HorizontalTermLine: React.FC<HorizontalTermLineProps> = ({
))}

{showMoreButton && (
<button
type="button"
onClick={() => setShowMore(!showMore)}
aria-label="Expand More"
>
<img
className={clsx("horizontal-term-line__expand", {
"horizontal-term-line__expand--expanded": showMore,
})}
src="icons/collection/ExpandMore.svg"
alt=""
/>
</button>
<ButtonExpand showMore={showMore} setShowMore={setShowMore} />
)}
</div>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.horizontal-term-line {
display: flex;
align-items: center;
align-items: baseline;
flex-wrap: wrap;
white-space: nowrap;
gap: $s-sm;
Expand All @@ -9,19 +9,4 @@
* {
font-size: 12px;
}

&__list {
display: flex;
flex-wrap: wrap;
gap: $s-sm;
}

&__expand {
cursor: pointer;
transition: transform 0.3s ease-in-out;

&--expanded {
transform: scaleY(-1);
}
}
}

0 comments on commit b2ea9e9

Please sign in to comment.