Skip to content

Commit

Permalink
#25 - feat: implement datagrid sort and improve styling
Browse files Browse the repository at this point in the history
  • Loading branch information
svenvandescheur authored Feb 6, 2024
1 parent 1dc92ce commit a0c7f56
Show file tree
Hide file tree
Showing 16 changed files with 525 additions and 156 deletions.
4 changes: 2 additions & 2 deletions src/components/badge/badge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export type BadgeProps = React.PropsWithChildren<{
* @constructor
*/
export const Badge: React.FC<BadgeProps> = ({ children, ...props }) => (
<div className="mykn-badge" {...props}>
<span className="mykn-badge" {...props}>
{children}
</div>
</span>
);
6 changes: 5 additions & 1 deletion src/components/boolean/boolean.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@
color: var(--theme-color-success-body);
}

&--explicit#{&}--value-false {
&--value-false {
background-color: var(--theme-color-danger-background);
color: var(--theme-color-danger-body);
}

&--value-false:not(#{&}--explicit) {
visibility: hidden;
}
}
5 changes: 3 additions & 2 deletions src/components/boolean/boolean.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ export const False: Story = {
play: ({ canvasElement }) => {
const canvas = within(canvasElement);
const boolean = canvas.getByLabelText("This value is false");
expect(boolean).toBeVisible();
expect(boolean.children).toHaveLength(0);
expect(boolean).not.toBeVisible();
expect(boolean.children).toHaveLength(1);
},
};

Expand All @@ -51,6 +51,7 @@ export const ExplicitFalse: Story = {
play: ({ canvasElement }) => {
const canvas = within(canvasElement);
const boolean = canvas.getByLabelText("This value is false");
expect(boolean).toBeVisible();
expect(boolean.children).toHaveLength(1);
},
};
Expand Down
6 changes: 3 additions & 3 deletions src/components/boolean/boolean.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const Boolean: React.FC<BooleanProps> = ({
labelFalse,
...props
}) => (
<div
<span
className={clsx("mykn-boolean", `mykn-boolean--value-${value}`, {
"mykn-boolean--explicit": explicit,
})}
Expand All @@ -41,6 +41,6 @@ export const Boolean: React.FC<BooleanProps> = ({
aria-label={value ? labelTrue : labelFalse}
>
{value && <Outline.CheckIcon />}
{!value && explicit && <Outline.XMarkIcon />}
</div>
{!value && <Outline.XMarkIcon />}
</span>
);
44 changes: 38 additions & 6 deletions src/components/button/button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
--mykn-button-color-background: var(--theme-color-primary-800);
--mykn-button-color-shadow: var(--theme-shade-1000);
--mykn-button-color-text: var(--theme-shade-0);
--mykn-button-font-size: var(--typography-font-size-body-s);
--mykn-button-font-weight: var(--typography-font-weight-normal);
--mykn-button-line-height: var(--typography-line-height-body-s);
--mykn-button-height: auto;
--mykn-button-width: auto;
--mykn-button-offset: 0px;
--mykn-button-padding-v: var(--spacing-v-s);
--mykn-button-padding-h: var(--spacing-h-s);
--mykn-button-padding-v: 0;
--mykn-button-padding-h: 0;

align-items: center;
appearance: none;
Expand All @@ -22,20 +25,45 @@
color: var(--mykn-button-color-text);
cursor: pointer;
display: inline-flex;
flex-wrap: wrap;
gap: 0.5em;
height: var(--mykn-button-height);
font-family: Inter, sans-serif;
font-size: var(--typography-font-size-body-s);
font-size: var(--mykn-button-font-size);
font-weight: var(--mykn-button-font-weight);
justify-content: center;
line-height: var(--typography-line-height-body-s);
line-height: var(--mykn-button-line-height);
text-align: center;
text-decoration: none;
transition: all var(--animation-duration-fast)
var(--animation-timing-function);
transform: translateY(var(--mykn-button-offset));
width: var(--mykn-button-width);

&--bold {
--mykn-button-font-weight: var(--typography-font-weight-bold);
}

&--justify {
--mykn-button-width: 100%;
}

&--muted {
--mykn-button-color-text: var(--typography-color-muted) !important;
}

&--pad-h {
--mykn-button-padding-h: var(--spacing-h-s);
}

&--pad-v {
--mykn-button-padding-v: var(--spacing-v-s);
}

&--size-xs {
--mykn-button-font-size: var(--typography-font-size-body-xs);
--mykn-button-line-height: var(--typography-line-height-body-xs);
}

&--square {
--mykn-button-height: calc(
var(--typography-line-height-body-s) + 2 * var(--spacing-v-s)
Expand All @@ -49,7 +77,7 @@
}

&--variant-primary {
&#{$self}--active, // TODO
&#{$self}--active, // TODO
&:focus,
&:hover {
--mykn-button-color-background: var(--theme-color-primary-700);
Expand Down Expand Up @@ -114,4 +142,8 @@
--mykn-button-offset: 0px;
}
}

&--wrap {
flex-wrap: wrap;
}
}
104 changes: 78 additions & 26 deletions src/components/button/button.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,66 +1,118 @@
import type { Meta, StoryObj } from "@storybook/react";
import { userEvent } from "@storybook/test";
import React from "react";

import { Toolbar } from "../toolbar";
import { Button, ButtonLink } from "./button";

const meta = {
title: "Controls/Button",
component: Button,
render: ({ ...args }) => (
<Toolbar>
<Button {...args} variant="primary">
Primary Button
</Button>
<Button {...args} variant="transparent">
Tranparent Button
</Button>
<Button {...args} variant="outline">
Outline Button
</Button>
</Toolbar>
),
} satisfies Meta<typeof Button>;

export default meta;
type Story = StoryObj<typeof meta>;

export const ButtonComponent: Story = {
export const Buttons: Story = {
args: {},
};

export const ActiveButtons: Story = {
args: {
children: "The quick brown fox jumps over the lazy dog.",
active: true,
},
};

export const TransparentButton: Story = {
export const BoldButtons: Story = {
args: {
children: "The quick brown fox jumps over the lazy dog.",
variant: "transparent",
bold: true,
},
};

export const ButtonAnimatesOnHoverAndClick: Story = {
export const JustifiedButtons: Story = {
args: {
children: "The quick brown fox jumps over the lazy dog.",
justify: true,
},
play: async () => {
await userEvent.tab({ delay: 10 });
};

export const MutedButtons: Story = {
args: {
muted: true,
},
};

export const ButtonLinkComponent: StoryObj<typeof ButtonLink> = {
export const PadlessButtons: Story = {
args: {
children: "The quick brown fox jumps over the lazy dog.",
href: "https://www.example.com",
target: "_blank",
pad: false,
},
render: (args) => <ButtonLink {...args} />,
};

export const TransparentButtonLink: StoryObj<typeof ButtonLink> = {
export const HorizontallyPaddedButtons: Story = {
args: {
children: "The quick brown fox jumps over the lazy dog.",
href: "https://www.example.com",
target: "_blank",
variant: "transparent",
pad: "h",
},
render: (args) => <ButtonLink {...args} />,
};

export const ButtonLinkAnimatesOnHoverAndClick: StoryObj<typeof ButtonLink> = {
export const VerticallyPaddedButtons: Story = {
args: {
pad: "v",
},
};

export const SmallerButtonText: Story = {
args: {
size: "xs",
},
};

export const SquareButtons: Story = {
args: {
square: true,
},
render: ({ ...args }) => (
<Toolbar>
<Button {...args} variant="primary">
1
</Button>
<Button {...args} variant="transparent">
2
</Button>
<Button {...args} variant="outline">
3
</Button>
</Toolbar>
),
};

export const ButtonLinkComponent: StoryObj<typeof ButtonLink> = {
args: {
children: "The quick brown fox jumps over the lazy dog.",
href: "https://www.example.com",
target: "_blank",
},
play: async () => {
await userEvent.tab({ delay: 10 });
},
render: (args) => <ButtonLink {...args} />,
render: ({ ...args }) => (
<Toolbar>
<ButtonLink {...args} variant="primary">
Primary ButtonLink
</ButtonLink>
<ButtonLink {...args} variant="transparent">
Tranparent ButtonLink
</ButtonLink>
<ButtonLink {...args} variant="outline">
Outline ButtonLink
</ButtonLink>
</Toolbar>
),
};
Loading

0 comments on commit a0c7f56

Please sign in to comment.