Skip to content

Commit aaa4f52

Browse files
authored
Add disabled prop to ButtonLink (#1008)
- Migrates ButtonLink to Astro, and adds a disabled prop to it. - Removes redundant ButtonWithTitle component. See https://add-disabled-prop.ep-preview.click/programme/mentorship/ for example Closes #978
1 parent c5f28a5 commit aaa4f52

File tree

17 files changed

+62
-128
lines changed

17 files changed

+62
-128
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
import type React from 'react';
3+
4+
export interface Props {
5+
url?: string;
6+
children: React.ReactNode;
7+
disabled?: boolean;
8+
className?: string;
9+
secondary?: boolean;
10+
isExternal?: boolean;
11+
}
12+
13+
const { url, className = "", secondary = false, disabled = false, isExternal} = Astro.props;
14+
const resolvedIsExternal = isExternal !== undefined ? isExternal : url?.startsWith("http");
15+
---
16+
17+
<a
18+
class={`font-bold text-lg px-4 py-4 bg-button rounded-[60px] inline-block leading-4 hover:bg-button-hover not-prose
19+
${secondary || disabled ? "bg-primary text-white hover:bg-primary-hover" : "text-text-inverted"}
20+
${secondary ? "text-text" : ""}
21+
${className || ""}
22+
${disabled ? "opacity-50 pointer-events-none" : ""}`}
23+
href={url}
24+
>
25+
<slot />
26+
27+
{resolvedIsExternal && (
28+
<span class="inline-block ml-1 font-system text-lg leading-4">
29+
30+
</span>
31+
)}
32+
</a>

src/components/button-link/button-link.tsx

Lines changed: 0 additions & 43 deletions
This file was deleted.

src/components/button-link/index.tsx

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/components/button-with-title/button-with-title.tsx

Lines changed: 0 additions & 22 deletions
This file was deleted.

src/components/button-with-title/index.tsx

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/components/button/button.tsx

Lines changed: 0 additions & 27 deletions
This file was deleted.

src/components/button/index.tsx

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/components/card/card.astro

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
import type { ImageMetadata } from "astro";
33
import { Image } from "astro:assets";
4-
import { ButtonLink } from "../button-link/button-link";
4+
import ButtonLink from "../button-link/button-link.astro";
55
66
export interface Props {
77
title: string;
@@ -28,7 +28,7 @@ const { title, subtitle, url, image } = Astro.props;
2828
<h3 class="text-3xl font-bold mt-2 mb-4 text-primary">{title}</h3>
2929
</a>
3030
<ButtonLink
31-
href={url}
31+
url={url}
3232
className="mb-4"
3333
isExternal={false}
3434
>

src/components/header/header-actions.astro

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
import { ButtonLink } from "../button-link";
2+
import ButtonLink from "../button-link/button-link.astro";
33
import HeaderButton from "./header-button.astro";
44
55
export interface Props {
@@ -15,17 +15,17 @@ const IS_LIVE = false;
1515
{
1616
!mobile ? (
1717
<>
18-
<ButtonLink secondary href="https://www.europython-society.org/coc/">
18+
<ButtonLink secondary url="https://www.europython-society.org/coc/">
1919
<abbr title="Code of Conduct" class="no-underline md:hidden">
2020
CoC
2121
</abbr>
2222
<span class="hidden md:inline">Code of Conduct</span>
2323
</ButtonLink>
24-
<ButtonLink href="https://voting.europython.eu" className="hidden md:block">
24+
<ButtonLink url="https://voting.europython.eu" className="hidden md:block">
2525
<span>Community vote</span>
2626
</ButtonLink>
2727
{IS_LIVE && (
28-
<ButtonLink href="/live">
28+
<ButtonLink url="/live">
2929
Live
3030
<span class="hidden md:inline"> 📺</span>
3131
</ButtonLink>

src/components/hero-section/prague.astro

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
import Prose from "../prose/prose.astro";
3-
import { ButtonLink } from "../button-link";
3+
import ButtonLink from "../button-link/button-link.astro";
44
import { Title } from "../typography/title";
55
import { Image } from "astro:assets";
66
@@ -31,12 +31,12 @@ import venueImage from "./prague.png";
3131
</Prose>
3232

3333
<div class="space-x-4 mb-5">
34-
<ButtonLink href="/where">
34+
<ButtonLink url="/where">
3535
Where is EuroPython?
3636
</ButtonLink>
3737
</div>
3838
<div class="space-x-12">
39-
<ButtonLink href="/explore">
39+
<ButtonLink url="/explore">
4040
Explore Prague
4141
</ButtonLink>
4242
</div>

0 commit comments

Comments
 (0)