Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: refactor Button and Anchor #492

Merged
merged 1 commit into from
Apr 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions examples/with-vite/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,14 @@ module.exports = {
<Button>Button</Button>
</div>
<div className="mb-2 flex flex-wrap gap-2">
<Anchor link="https://www.google.com">Anchor as a button</Anchor>
<Anchor link="https://www.google.com">
<Anchor href="https://www.google.com">Anchor as a button</Anchor>
<Anchor href="https://www.google.com">
Anchor as a button lorem ipsum
</Anchor>
<Anchor link="https://www.google.com">
<Anchor href="https://www.google.com">
Anchor as a button lorem ipsum dolor
</Anchor>
<Anchor link="https://www.google.com">
<Anchor href="https://www.google.com">
Anchor as a button lorem ipsum dolor sit amet
</Anchor>
</div>
Expand Down
8 changes: 4 additions & 4 deletions examples/with-webpack/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,14 @@ module.exports = {
<Button>Button</Button>
</div>
<div className="mb-2 flex flex-wrap gap-2">
<Anchor link="https://www.google.com">Anchor as a button</Anchor>
<Anchor link="https://www.google.com">
<Anchor href="https://www.google.com">Anchor as a button</Anchor>
<Anchor href="https://www.google.com">
Anchor as a button lorem ipsum
</Anchor>
<Anchor link="https://www.google.com">
<Anchor href="https://www.google.com">
Anchor as a button lorem ipsum dolor
</Anchor>
<Anchor link="https://www.google.com">
<Anchor href="https://www.google.com">
Anchor as a button lorem ipsum dolor sit amet
</Anchor>
</div>
Expand Down
71 changes: 47 additions & 24 deletions packages/documentation/src/Components/Anchor.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,40 +6,63 @@ export default {
meta: {
importName: "Anchor",
},
args: {
fullWidth: false,
mode: "system",
focusMode: "system",
raw: false,
href: "https://example.com",
noBorder: false,
size: "small",
noTruncate: false,
noNewWindowIcon: false,
},
argTypes: {
mode: {
options: ["dark", "light", "system", "alt-system"],
control: { type: "radio" },
},
focusMode: {
options: ["dark", "light", "system", "alt-system"],
control: { type: "radio" },
},
size: {
options: ["small", "medium", "large"],
control: { type: "radio" },
},
},
};

export const Basic: Story<any> = (args) => (
<div className="flex flex-wrap">
<div className="flex flex-wrap gap-2">
<Anchor {...args}>Anchor as a button</Anchor>
<Anchor {...args}>Anchor as a button lorem ipsum</Anchor>
<Anchor {...args}>Anchor as a button lorem ipsum dolor</Anchor>
<Anchor {...args}>Anchor as a button lorem ipsum dolor sit amet</Anchor>
</div>
);

Basic.args = {
fullWidth: false,
mode: "system",
focusMode: "system",
raw: false,
link: "https://www.google.com",
noBorder: false,
size: "small",
noTruncate: false,
spacing: { r: 2, b: 2 },
export const NewWindow: Story<any> = (args) => (
<div className="flex flex-wrap gap-2">
<Anchor {...args}>Anchor as a button</Anchor>
<Anchor {...args}>Anchor as a button lorem ipsum</Anchor>
<Anchor {...args}>Anchor as a button lorem ipsum dolor</Anchor>
<Anchor {...args}>Anchor as a button lorem ipsum dolor sit amet</Anchor>
</div>
);
NewWindow.args = {
target: "_blank",
};

Basic.argTypes = {
mode: {
options: ["dark", "light", "system", "alt-system"],
control: { type: "radio" },
},
focusMode: {
options: ["dark", "light", "system", "alt-system"],
control: { type: "radio" },
},
size: {
options: ["small", "medium", "large"],
control: { type: "radio" },
},
export const Truncate: Story<any> = (args) => (
<div className="flex flex-wrap gap-2">
<Anchor {...args}>Anchor as a button</Anchor>
<Anchor {...args}>Anchor as a button lorem ipsum</Anchor>
<Anchor {...args}>Anchor as a button lorem ipsum dolor</Anchor>
<Anchor {...args}>Anchor as a button lorem ipsum dolor sit amet</Anchor>
</div>
);

Truncate.args = {
className: "w-44 sm:w-52",
};
89 changes: 60 additions & 29 deletions packages/documentation/src/Components/Button.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,44 @@ export default {
meta: {
importName: "Button",
},
args: {
disabled: false,
fullWidth: false,
mode: "system",
focusMode: "system",
size: "medium",
raw: false,
noBorder: false,
variant: "primary",
noTruncate: false,
},
argTypes: {
mode: {
options: ["dark", "light", "system", "alt-system"],
control: { type: "radio" },
},
focusMode: {
options: ["dark", "light", "system", "alt-system"],
control: { type: "radio" },
},
size: {
options: ["small", "medium", "large"],
control: { type: "radio" },
},
variant: {
options: ["primary", "secondary", "danger"],
control: { type: "radio" },
},
},
};

export const Basic: Story<any> = (args) => {
return (
<>
<div className="flex flex-wrap gap-2">
<Button {...args}>Button</Button>
<Button {...args}>Button</Button>
<Button {...args}>Button</Button>
<Button {...args}>Button lorem ipsum</Button>
<Button {...args}>Button lorem ipsum dolor</Button>
<Button {...args}>Button lorem ipsum dolor sit amet</Button>
</div>

<p>
Expand All @@ -35,31 +64,33 @@ export const Basic: Story<any> = (args) => {
);
};

Basic.args = {
disabled: false,
fullWidth: false,
mode: "system",
focusMode: "system",
size: "medium",
raw: false,
noBorder: false,
variant: "primary",
export const Truncate: Story<any> = (args) => {
return (
<>
<div className="flex flex-wrap gap-2">
<Button {...args}>Button lorem ipsum</Button>
<Button {...args}>Button lorem ipsum dolor</Button>
<Button {...args}>Button lorem ipsum dolor sit amet</Button>
</div>

<p>
The following row is having the <code>variant</code> prop hard-coded:
</p>
<div className="flex flex-wrap gap-2">
<Button {...args} variant="primary">
Button lorem ipsum
</Button>
<Button {...args} variant="secondary">
Button lorem ipsum dolor
</Button>
<Button {...args} variant="danger">
Button lorem ipsum dolor sit amet
</Button>
</div>
</>
);
};
Basic.argTypes = {
mode: {
options: ["dark", "light", "system", "alt-system"],
control: { type: "radio" },
},
focusMode: {
options: ["dark", "light", "system", "alt-system"],
control: { type: "radio" },
},
size: {
options: ["small", "medium", "large"],
control: { type: "radio" },
},
variant: {
options: ["primary", "secondary", "danger"],
control: { type: "radio" },
},

Truncate.args = {
className: "w-44 sm:w-52",
};
8 changes: 4 additions & 4 deletions packages/documentation/src/Components/Header.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,14 @@ const CommonTemplate = () => {
<Button>Button</Button>
</div>
<div className="mb-2 flex flex-wrap gap-2">
<Anchor link="https://www.google.com">Anchor as a button</Anchor>
<Anchor link="https://www.google.com">
<Anchor href="https://www.google.com">Anchor as a button</Anchor>
<Anchor href="https://www.google.com">
Anchor as a button lorem ipsum
</Anchor>
<Anchor link="https://www.google.com">
<Anchor href="https://www.google.com">
Anchor as a button lorem ipsum dolor
</Anchor>
<Anchor link="https://www.google.com">
<Anchor href="https://www.google.com">
Anchor as a button lorem ipsum dolor sit amet
</Anchor>
</div>
Expand Down
8 changes: 4 additions & 4 deletions packages/documentation/src/Styles/DarkMode.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,14 @@ const CommonTemplate = () => {
<Button>Button</Button>
</div>
<div className="mb-2 flex flex-wrap gap-2">
<Anchor link="https://www.google.com">Anchor as a button</Anchor>
<Anchor link="https://www.google.com">
<Anchor href="https://www.google.com">Anchor as a button</Anchor>
<Anchor href="https://www.google.com">
Anchor as a button lorem ipsum
</Anchor>
<Anchor link="https://www.google.com">
<Anchor href="https://www.google.com">
Anchor as a button lorem ipsum dolor
</Anchor>
<Anchor link="https://www.google.com">
<Anchor href="https://www.google.com">
Anchor as a button lorem ipsum dolor sit amet
</Anchor>
</div>
Expand Down
16 changes: 0 additions & 16 deletions packages/ui-components/src/common/__tests__/utilities.test.tsx

This file was deleted.

16 changes: 0 additions & 16 deletions packages/ui-components/src/common/utilities.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/ui-components/src/components/Anchor/Anchor.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";

import { ButtonLink } from "..";
import { ButtonLink } from "../Button/ButtonLink";
import type { AnchorProps } from "./AnchorTypes";

export const Anchor = React.forwardRef<HTMLAnchorElement, AnchorProps>(
Expand Down
Loading
Loading