Skip to content

Commit

Permalink
(HDS-1834) change Linkbox size to enum
Browse files Browse the repository at this point in the history
  • Loading branch information
mrTuomoK committed Apr 29, 2024
1 parent 4ba9675 commit 60a2baa
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 24 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- [Component] What has been changed
- [Notification] Change auto closing notification progressbar to decrease instead of increase.
- [LinkBox] Change size prop to an enum (LinkboxSize.Small, LinkboxSize.Medium, LinkboxSize.Large), not a breaking change though since the enum values are identical to the old ones.

#### Fixed

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';

import { Linkbox } from './Linkbox';
import { Linkbox, LinkboxSize } from './Linkbox';

export default {
component: Linkbox,
Expand Down Expand Up @@ -49,23 +49,23 @@ export const External = () => (

export const SmallSize = () => (
<div style={{ width: '288px' }}>
<Linkbox linkboxAriaLabel="Linkbox: HDS" linkAriaLabel="HDS" href="https://hds.hel.fi" size="small">
<Linkbox linkboxAriaLabel="Linkbox: HDS" linkAriaLabel="HDS" href="https://hds.hel.fi" size={LinkboxSize.Small}>
<div style={{ height: '192px' }} />
</Linkbox>
</div>
);

export const MediumSize = () => (
<div style={{ width: '320px' }}>
<Linkbox linkboxAriaLabel="Linkbox: HDS" linkAriaLabel="HDS" href="https://hds.hel.fi" size="medium">
<Linkbox linkboxAriaLabel="Linkbox: HDS" linkAriaLabel="HDS" href="https://hds.hel.fi" size={LinkboxSize.Medium}>
<div style={{ height: '224px' }} />
</Linkbox>
</div>
);

export const LargeSize = () => (
<div style={{ width: '400px' }}>
<Linkbox linkboxAriaLabel="Linkbox: HDS" linkAriaLabel="HDS" href="https://hds.hel.fi" size="large">
<Linkbox linkboxAriaLabel="Linkbox: HDS" linkAriaLabel="HDS" href="https://hds.hel.fi" size={LinkboxSize.Large}>
<div style={{ height: '296px' }} />
</Linkbox>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';

import { Linkbox } from './Linkbox';
import { Linkbox, LinkboxSize } from './Linkbox';

export default {
component: Linkbox,
Expand Down Expand Up @@ -75,7 +75,7 @@ export const SmallSize = () => (
href="https://hds.hel.fi"
heading="Linkbox title"
text="Linkbox text"
size="small"
size={LinkboxSize.Small}
/>
</div>
);
Expand All @@ -88,7 +88,7 @@ export const MediumSize = () => (
href="https://hds.hel.fi"
heading="Linkbox title"
text="Linkbox text"
size="medium"
size={LinkboxSize.Medium}
/>
</div>
);
Expand All @@ -100,6 +100,6 @@ export const LargeSize = () => (
href="https://hds.hel.fi"
heading="Linkbox title"
text="Linkbox text"
size="large"
size={LinkboxSize.Large}
/>
);
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';

import { Linkbox } from './Linkbox';
import { Linkbox, LinkboxSize } from './Linkbox';
/* eslint-disable @typescript-eslint/ban-ts-comment */
// @ts-ignore
import smallImage from '../../assets/img/linkbox/placeholder-small.png';
Expand Down Expand Up @@ -88,7 +88,7 @@ export const SmallSize = () => (
heading="Linkbox title"
text="Linkbox text"
imgProps={{ src: smallImage, width: 284, height: 181 }}
size="small"
size={LinkboxSize.Small}
/>
</div>
);
Expand All @@ -102,7 +102,7 @@ export const MediumSize = () => (
heading="Linkbox title"
text="Linkbox text"
imgProps={{ src: mediumImage, width: 384, height: 245 }}
size="medium"
size={LinkboxSize.Medium}
/>
</div>
);
Expand All @@ -116,7 +116,7 @@ export const LargeSize = () => (
heading="Linkbox title"
text="Linkbox text"
imgProps={{ src: largeImage, width: 567, height: 363 }}
size="large"
size={LinkboxSize.Large}
/>
</div>
);
14 changes: 7 additions & 7 deletions site/src/docs/components/linkbox/code.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ slug: '/components/linkbox/code'
title: 'Linkbox - Code'
---

import { Linkbox } from 'hds-react';
import { Linkbox, LinkboxSize } from 'hds-react';
import { withPrefix } from "gatsby"
import TabsLayout from './tabs.mdx';

Expand Down Expand Up @@ -164,10 +164,10 @@ import { Linkbox } from 'hds-react';
</Playground>

### Linkbox size variants
<Playground scope={{ Linkbox, withPrefix }}>
<Playground scope={{ Linkbox, LinkboxSize, withPrefix }}>

```jsx
import { Linkbox } from 'hds-react';
import { Linkbox, LinkboxSize } from 'hds-react';

() => (
<div style={{ backgroundColor: 'var(--color-black-5)', padding: 'var(--spacing-s)' }}>
Expand All @@ -178,7 +178,7 @@ import { Linkbox } from 'hds-react';
href="https://hds.hel.fi"
heading="Linkbox title"
text="Linkbox text"
size="small"
size={LinkboxSize.Small}
imgProps={{ src: withPrefix('/images/foundation/visual-assets/placeholders/[email protected]'), width: 284, height: 181 }}
/>
</div>
Expand All @@ -189,7 +189,7 @@ import { Linkbox } from 'hds-react';
href="https://hds.hel.fi"
heading="Linkbox title"
text="Linkbox text"
size="medium"
size={LinkboxSize.Medium}
imgProps={{ src: withPrefix('/images/foundation/visual-assets/placeholders/[email protected]'), width: 384, height: 245 }}
/>
</div>
Expand All @@ -200,7 +200,7 @@ import { Linkbox } from 'hds-react';
href="https://hds.hel.fi"
heading="Linkbox title"
text="Linkbox text"
size="large"
size={LinkboxSize.Large}
imgProps={{ src: withPrefix('/images/foundation/visual-assets/placeholders/[email protected]'), width: 567, height: 363 }}
/>
</div>
Expand All @@ -227,7 +227,7 @@ Note! You can find the full list of properties in the <Link openInNewTab openInN
| `openInExternalDomainAriaLabel` | Aria-label which is read if the link is external. | `string` | - |
| `openInNewTab` | If set to true, the link opens in a new tab. | `boolean` | false |
| `openInNewTabAriaLabel` | Aria-label which is read if the link is opened in a new tab. | `string` | - |
| `size` | Controls the size of the Linkbox. | `"small"`, `"medium"`, `"large"` | `"medium"` |
| `size` | Controls the size of the Linkbox. | `LinkboxSize.Small`, `LinkboxSize.Medium`, `LinkboxSize.Large` | `LinkboxSize.Medium` |
| `href` | Hypertext reference of the link. | `string` | - |
| `linkAriaLabel` | Aria-label for the link (arrow or external icon) that is located at the bottom of the linkbox. | `string` | - |
| `linkboxAriaLabel` | Aria label for the whole linkbox region. Remember to tell users of assistive technology that they are inside a linkbox. Check storybook examples on how it can be done. | `string` | - |
Expand Down
10 changes: 5 additions & 5 deletions site/src/docs/components/linkbox/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ title: 'Linkbox'
navTitle: 'Linkbox'
---

import { Linkbox } from 'hds-react';
import { Linkbox, LinkboxSize } from 'hds-react';
import { withPrefix } from "gatsby"
import TabsLayout from './tabs.mdx';

Expand Down Expand Up @@ -170,7 +170,7 @@ HDS offers styling for a Linkbox with an image as its content.

#### Linkbox size variants

HDS Linkbox includes three (3) size variants; small, default, and large.
HDS Linkbox includes three (3) size variants; small, default, and large (LinkboxSize.Small, LinkboxSize.Medium and LinkboxSize.Large).
You can use different sizes depending on the screen size or use case.
Size variants differ in (default) heading size and inner spacing. Use the size property to alter the size.

Expand All @@ -182,7 +182,7 @@ Size variants differ in (default) heading size and inner spacing. Use the size p
href="https://hds.hel.fi"
heading="Linkbox title"
text="Linkbox text"
size="small"
size={LinkboxSize.Small}
imgProps={{ src: withPrefix('/images/foundation/visual-assets/placeholders/[email protected]'), width: 284, height: 181 }}
/>
</div>
Expand All @@ -193,7 +193,7 @@ Size variants differ in (default) heading size and inner spacing. Use the size p
href="https://hds.hel.fi"
heading="Linkbox title"
text="Linkbox text"
size="medium"
size={LinkboxSize.Medium}
imgProps={{ src: withPrefix('/images/foundation/visual-assets/placeholders/[email protected]'), width: 384, height: 245 }}
/>
</div>
Expand All @@ -204,7 +204,7 @@ Size variants differ in (default) heading size and inner spacing. Use the size p
href="https://hds.hel.fi"
heading="Linkbox title"
text="Linkbox text"
size="large"
size={LinkboxSize.Large}
imgProps={{ src: withPrefix('/images/foundation/visual-assets/placeholders/[email protected]'), width: 567, height: 363 }}
/>
</div>
Expand Down

0 comments on commit 60a2baa

Please sign in to comment.