Skip to content

Commit

Permalink
Add fullwidth property to tile
Browse files Browse the repository at this point in the history
  • Loading branch information
aurorascharff committed Sep 11, 2024
1 parent f3c8ea2 commit 4fc0565
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/css/src/tile/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ See [Storybook](https://miljodir.github.io/md-components) for examples and more
## Tile horizontal

```html
<a className="md-tile [md-tile--secondary, md-tile--small, md-tile--medium]" href="{href}" onClick="{handleClick}">
<a className="md-tile [md-tile--secondary, md-tile--small, md-tile--medium, md-tile--fullWidth]" href="{href}" onClick="{handleClick}">
<div className="md-tile__content">
<div className="md-tile__content-icon">{icon}</div>
<div className="md-tile__content-text">
Expand Down
8 changes: 8 additions & 0 deletions packages/css/src/tile/tile.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,28 @@
gap: 1.5em;
text-align: start;
width: 440px;
min-width: 440px;
max-width: 100%;
transition: all 0.15s ease-in-out;
}

.md-tile--medium {
width: 424px;
min-width: 424px;
}

.md-tile--small {
width: 320px;
min-width: 320px;
gap: 1em;
padding: 16px;
}

.md-tile--fullWidth {
width: 100%;
min-width: 100%;
}

.md-tile--secondary {
background-color: var(--mdSecondaryColor40);
}
Expand Down
3 changes: 3 additions & 0 deletions packages/react/src/tiles/MdTile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export type MdTileProps = {
description?: string;
href?: string;
theme?: 'primary' | 'secondary';
fullWidth?: boolean;
disabled?: boolean;
mode?: 'large' | 'medium' | 'small';
icon?: React.ReactNode;
Expand All @@ -20,6 +21,7 @@ const MdTile: React.FC<MdTileProps> = ({
description,
href,
theme = 'primary',
fullWidth = false,
mode = 'large',
disabled = false,
icon = null,
Expand All @@ -34,6 +36,7 @@ const MdTile: React.FC<MdTileProps> = ({
'md-tile--secondary': theme && theme === 'secondary',
'md-tile--medium': mode === 'medium',
'md-tile--small': mode === 'small',
'md-tile--fullWidth': !!fullWidth,
},
otherProps.className,
);
Expand Down
2 changes: 1 addition & 1 deletion stories/Button.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export default {
interface ButtonArgs {
label: string;
disabled: boolean;
theme: string;
theme: 'primary' | 'secondary' | 'danger' | 'tertiary';
small: boolean;
}

Expand Down
12 changes: 12 additions & 0 deletions stories/Tile.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@ export default {
},
control: { type: 'boolean' },
},
fullWidth: {
description: 'Make tile full width.',
table: {
defaultValue: { summary: 'false' },
type: {
summary: 'boolean',
},
},
control: { type: 'boolean' },
},
theme: {
type: { name: 'string' },
description: 'Color theme for tile.',
Expand Down Expand Up @@ -115,6 +125,7 @@ const Template = (args: Args) => {
description="Oversikt over dine målestasjoner"
href={args.href}
mode={args.mode}
fullWidth={args.fullWidth}
theme={args.theme}
disabled={args.disabled}
preventDefault={args.preventDefault}
Expand All @@ -127,6 +138,7 @@ export const Tile = Template.bind({});
Tile.args = {
href: '#',
theme: 'primary',
fullWidth: false,
mode: 'large',
disabled: false,
preventDefault: true,
Expand Down

0 comments on commit 4fc0565

Please sign in to comment.