From ab45cb7e8009d0cb77df94727a7489435b31a412 Mon Sep 17 00:00:00 2001 From: Uyen Doan <56598021+smmr-dn@users.noreply.github.com> Date: Mon, 19 Aug 2024 15:00:52 -0500 Subject: [PATCH] Add Astro Radio Component (#2191) Co-authored-by: Uyen Doan --- apps/css-workshop/src/components/Radio.astro | 43 +++ apps/css-workshop/src/pages/dialog.astro | 26 +- apps/css-workshop/src/pages/fieldset.astro | 22 +- apps/css-workshop/src/pages/radio.astro | 333 ++++--------------- 4 files changed, 124 insertions(+), 300 deletions(-) create mode 100644 apps/css-workshop/src/components/Radio.astro diff --git a/apps/css-workshop/src/components/Radio.astro b/apps/css-workshop/src/components/Radio.astro new file mode 100644 index 00000000000..261ca2c6426 --- /dev/null +++ b/apps/css-workshop/src/components/Radio.astro @@ -0,0 +1,43 @@ +--- +type Props = { + status?: 'positive' | 'warning' | 'negative'; + disabled?: boolean; + checked?: boolean; + labelPosition?: 'left' | 'right'; + value: string; + name: string; +} & astroHTML.JSX.HTMLAttributes; + +const { disabled, status, class: className, labelPosition, ...props } = Astro.props; +--- + + diff --git a/apps/css-workshop/src/pages/dialog.astro b/apps/css-workshop/src/pages/dialog.astro index eff16cadeb0..9f114b9d984 100644 --- a/apps/css-workshop/src/pages/dialog.astro +++ b/apps/css-workshop/src/pages/dialog.astro @@ -2,6 +2,7 @@ import Layout from './_layout.astro'; import Button_ from '../components/Button.astro'; import IconButton_ from '../components/IconButton.astro'; +import Radio_ from '../components/Radio.astro'; --- @@ -34,26 +35,11 @@ import IconButton_ from '../components/IconButton.astro';
Dialog Placement
- - - - - + Centered + Top-left + Top-right + Bottom-left + Bottom-right
diff --git a/apps/css-workshop/src/pages/fieldset.astro b/apps/css-workshop/src/pages/fieldset.astro index 4375fe0d01d..aa4a68e9cab 100644 --- a/apps/css-workshop/src/pages/fieldset.astro +++ b/apps/css-workshop/src/pages/fieldset.astro @@ -1,6 +1,7 @@ --- import Layout from './_layout.astro'; import Icon_ from '../components/Icon.astro'; +import Radio_ from '../components/Radio.astro'; --- @@ -37,24 +38,9 @@ import Icon_ from '../components/Icon.astro';
Color theme
- - - + Light + Dark + Match device
diff --git a/apps/css-workshop/src/pages/radio.astro b/apps/css-workshop/src/pages/radio.astro index f7a5e5f7748..112d07d98d1 100644 --- a/apps/css-workshop/src/pages/radio.astro +++ b/apps/css-workshop/src/pages/radio.astro @@ -1,6 +1,7 @@ --- import Layout from './_layout.astro'; import Icon_ from '../components/Icon.astro'; +import Radio_ from '../components/Radio.astro'; --- @@ -29,22 +30,10 @@ import Icon_ from '../components/Icon.astro';
Radio group label
- - - - + Option 1 + Option 2 + Option 3 + Option 4
Help message.
@@ -54,29 +43,10 @@ import Icon_ from '../components/Icon.astro';
Radio group label
- - - - + Option 1 + Option 2 + Option 3 + Option 4
Help message.
@@ -86,22 +56,10 @@ import Icon_ from '../components/Icon.astro';
Radio group label
- - - - + Option 1 + Option 2 + Option 3 + Option 4
@@ -113,22 +71,10 @@ import Icon_ from '../components/Icon.astro';
Radio group label
- - - - + Option 1 + Option 2 + Option 3 + Option 4
@@ -140,22 +86,10 @@ import Icon_ from '../components/Icon.astro';
Radio group label
- - - - + Option 1 + Option 2 + Option 3 + Option 4
@@ -167,30 +101,18 @@ import Icon_ from '../components/Icon.astro';
Radio group label
- - - - + + + + + + + + + + + +
Help message.
@@ -205,51 +127,20 @@ import Icon_ from '../components/Icon.astro';
Radio group label
- - - - + Option 1 + Option 2 + Option 3 + Option 4
Radio group label
- - - - + Option 1 + Option 2 + Option 3 + Option 4
@@ -259,22 +150,10 @@ import Icon_ from '../components/Icon.astro'; >
Radio group label
- - - - + Option 1 + Option 2 + Option 3 + Option 4
@@ -287,22 +166,10 @@ import Icon_ from '../components/Icon.astro'; >
Radio group label
- - - - + Option 1 + Option 2 + Option 3 + Option 4
@@ -315,22 +182,10 @@ import Icon_ from '../components/Icon.astro'; >
Radio group label
- - - - + Option 1 + Option 2 + Option 3 + Option 4
@@ -350,30 +205,11 @@ import Icon_ from '../components/Icon.astro'; flex-direction: column; align-items: flex-start;' > - - - - - - - - - + Option 1 + Option 2 + Option 3 + Option 4 + Option 5

Radio on right

@@ -384,49 +220,22 @@ import Icon_ from '../components/Icon.astro'; flex-direction: column; align-items: flex-end;' > - - - - - - - - - + Option 1 + Option 2 + + Option 3 + + + Option 4 + + + Option 5 +
- - - + Disabled option 1 + Disabled option 2