From b55d2d6402288a26b6f8be1e5a307d69b3ad2d75 Mon Sep 17 00:00:00 2001 From: Jamie Henson Date: Wed, 10 Jul 2024 17:30:29 +0100 Subject: [PATCH] chore: add means to style links as buttons with disabled state, port button docs to story --- package.json | 2 +- .../styles/Button.stories.tsx} | 109 ++++++++++++------ src/core/styles/buttons.css | 15 +++ tailwind.config.js | 2 +- 4 files changed, 92 insertions(+), 36 deletions(-) rename src/{pages/Buttons.mdx => core/styles/Button.stories.tsx} (67%) diff --git a/package.json b/package.json index 28105b8b5..d7096ff63 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@ably/ui", - "version": "14.1.3", + "version": "14.1.4", "description": "Home of the Ably design system library ([design.ably.com](https://design.ably.com)). It provides a showcase, development/test environment and a publishing pipeline for different distributables.", "repository": { "type": "git", diff --git a/src/pages/Buttons.mdx b/src/core/styles/Button.stories.tsx similarity index 67% rename from src/pages/Buttons.mdx rename to src/core/styles/Button.stories.tsx index b79d621b7..5f59b499a 100644 --- a/src/pages/Buttons.mdx +++ b/src/core/styles/Button.stories.tsx @@ -1,16 +1,13 @@ -import { Meta, Unstyled } from "@storybook/blocks"; -import Icon from "../core/Icon"; +import React from "react"; +import Icon from "../Icon"; - +export default { + title: "CSS/Button", +}; - -

Buttons

-
-

Different size buttons can be achieved by using padding and text utilities, see - examples below.

- -
-

Standard

+export const Standard = { + render: () => ( +
@@ -30,9 +27,12 @@ import Icon from "../core/Icon"; Unavailable secondary button
+ ), +}; -
-

Inverted

+export const Inverted = { + render: () => ( +
@@ -46,9 +46,12 @@ import Icon from "../core/Icon"; Unavailable secondary button
+ ), +}; -
-

With icons

+export const WithIcons = { + render: () => ( +
+ ), +}; -
+export const LinkStyledAsButton = { + render: () => ( + + ), +}; -
-
-

Extra small

- +export const ExtraSmall = { + render: () => ( +
+ - - + +
+ ), +}; -
-

Small

+export const Small = { + render: () => ( +
+ ), +}; -
-

Large

- +export const Large = { + render: () => ( +
+ - - + +
- -
- + ), +}; diff --git a/src/core/styles/buttons.css b/src/core/styles/buttons.css index ebc5528f6..23c53a6f7 100644 --- a/src/core/styles/buttons.css +++ b/src/core/styles/buttons.css @@ -121,4 +121,19 @@ .ui-chip-alt[data-selected]:focus { @apply bg-gui-active text-white; } + + .ui-btn.ui-btn-disabled, + .ui-btn-invert.ui-btn-disabled, + .ui-chip.ui-btn-disabled, + .ui-chip-alt.ui-btn-disabled { + @apply text-mid-grey bg-gui-unavailable cursor-not-allowed pointer-events-none select-none; + } + + .ui-btn-secondary.ui-btn-disabled { + @apply text-gui-unavailable border-gui-unavailable bg-white cursor-not-allowed pointer-events-none select-none; + } + + .ui-btn-secondary-invert.ui-btn-disabled { + @apply text-gui-unavailable border-gui-unavailable cursor-not-allowed pointer-events-none select-none; + } } diff --git a/tailwind.config.js b/tailwind.config.js index 687e45123..f1ad30381 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -1,5 +1,5 @@ module.exports = { - content: ["./src/**/*.{js,ts,tsx,mdx}"], + content: ["./src/**/*.{js,ts,tsx,mdx,stories.tsx}"], safelist: [ "w-1/2", "w-1/3",