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

Feat(anchor): hrefを任意プロパティに変更する #1341

Merged
merged 4 commits into from
Aug 26, 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
5 changes: 5 additions & 0 deletions .changeset/thirty-taxis-search.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@wizleap-inc/wiz-ui-react": minor
---

Feat(anchor): href を任意プロパティに変更する
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type Props<T extends ElementType> = BaseProps & {
children: ReactNode;
} & (
| {
href: string;
href?: string;
as?: never;
asProps?: never;
openInNewTab?: boolean;
Expand Down Expand Up @@ -63,8 +63,9 @@ const Anchor = forwardRef(
}: Props<T>,
ref: ForwardedRef<HTMLAnchorElement>
) => {
const isAnchor = "href" in props;
const LinkComponent = isAnchor ? "a" : props.as;
const isAnchor = "href" in props && props.as === undefined;
const LinkComponent = props.as || "a";

const linkProps = isAnchor
? {
href: props.href,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ export const Default: Story = {
},
},
},
args: {
href: "#",
},
args: {},
render: (args) => <WizAnchor {...args}>○○へ飛ぶ</WizAnchor>,
};

Expand All @@ -39,7 +37,6 @@ export const Color: Story = {
},
},
args: {
href: "#",
color: "red.800",
},
render: (args) => <WizAnchor {...args}>○○へ飛ぶ</WizAnchor>,
Expand All @@ -55,7 +52,6 @@ export const FontSize: Story = {
},
},
args: {
href: "#",
fontSize: "sm",
},
render: (args) => <WizAnchor {...args}>○○へ飛ぶ</WizAnchor>,
Expand All @@ -70,7 +66,6 @@ export const FontWeight: Story = {
},
},
args: {
href: "#",
fontWeight: "bold",
},
render: (args) => <WizAnchor {...args}>○○へ飛ぶ</WizAnchor>,
Expand All @@ -86,7 +81,6 @@ export const Icon: Story = {
},
},
args: {
href: "#",
icon: WizIArrowRight,
},
render: (args) => <WizAnchor {...args}>○○へ飛ぶ</WizAnchor>,
Expand All @@ -105,7 +99,6 @@ export const IconPosition: Story = {
},
},
args: {
href: "#",
icon: WizIArrowRight,
iconPosition: "right",
},
Expand Down
Loading