Skip to content

Commit

Permalink
Merge pull request #469 from ably/pubsub-required-fixes
Browse files Browse the repository at this point in the history
[WEB-3878] 14.5.0 - ProductTile, shadows, secondary Icon colours, review builds
  • Loading branch information
jamiehenson authored Sep 6, 2024
2 parents 07da0c6 + 87dde35 commit 4f7732e
Show file tree
Hide file tree
Showing 31 changed files with 1,316 additions and 332 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/review.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Review

on:
pull_request:
types: [labeled]

permissions:
contents: read
pages: write
id-token: write

jobs:
deploy-storybook:
if: ${{ github.event.label.name == 'review' }}
name: Deploy Storybook to GH Pages
runs-on: ubuntu-latest
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Build
run: yarn && yarn build-storybook
- name: Upload
uses: actions/upload-pages-artifact@v3.0.1
with:
path: preview
- id: deploy
name: Deploy to GitHub Pages
uses: actions/deploy-pages@v4
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ably/ui",
"version": "14.4.0",
"version": "14.5.0",
"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",
Expand Down
19 changes: 17 additions & 2 deletions src/core/Icon.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,37 @@
import React from "react";
import React, { CSSProperties } from "react";
import { defaultIconSecondaryColor } from "./Icon/secondary-colors";

type IconProps = {
name: string;
size?: string;
color?: string;
secondaryColor?: string;
additionalCSS?: string;
};

const convertTailwindClassToVar = (className: string) =>
className.replace(/text-([a-z0-9-]+)/gi, "var(--color-$1)");

const Icon = ({
name,
size = "0.75rem",
color = "",
secondaryColor = defaultIconSecondaryColor(name),
additionalCSS = "",
...additionalAttributes
}: IconProps) => (
<svg
className={`${color} ${additionalCSS}`}
style={{ width: size, height: size }}
style={
{
width: size,
height: size,
...(secondaryColor && {
"--ui-icon-secondary-color":
convertTailwindClassToVar(secondaryColor),
}),
} as CSSProperties
}
{...additionalAttributes}
>
<use xlinkHref={`#sprite-${name}`} />
Expand Down
26 changes: 26 additions & 0 deletions src/core/Icon/Icon.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -230,3 +230,29 @@ export const ProductIcons = {
export const Other = {
render: () => renderIcons(otherIcons),
};

export const IconWithSecondaryColor = {
render: () => (
<div className="flex items-center justify-center p-16 gap-24">
<Icon
name="icon-gui-check-circled-fill"
color="text-active-orange"
size="1.5rem"
/>
<Icon
name="icon-gui-check-circled-fill"
color="text-active-orange"
secondaryColor="text-neutral-1300"
size="1.5rem"
/>
</div>
),
parameters: {
docs: {
description: {
story:
"By setting the `secondaryColor` prop, you can change the color of the icon's secondary elements, if supported in the underlying SVG. You can set either a CSS variable directly, or use a Tailwind class.\n\nThe right-hand icon here (`icon-gui-check-circled-fill`) has this property applied, resulting in it having a dark checkmark.\n\nTo add support to an existing SVG, replace a `fill` attribute value with `var(--ui-icon-secondary-color)`.",
},
},
},
};
19 changes: 18 additions & 1 deletion src/core/Icon/__snapshots__/Icon.stories.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1244,7 +1244,7 @@ exports[`JS Components/Icon GUIIcons smoke-test 1`] = `
<div class="border inline-flex flex-0">
<div class="flex pi-checkered-bg">
<svg class="text-cool-black hover:text-active-orange"
style="width: 1.5rem; height: 1.5rem;"
style="width: 1.5rem; height: 1.5rem; --ui-icon-secondary-color: white;"
>
<use xlink:href="#sprite-icon-gui-check-circled-fill">
</use>
Expand Down Expand Up @@ -1705,6 +1705,23 @@ exports[`JS Components/Icon GUIIcons smoke-test 1`] = `
</div>
`;

exports[`JS Components/Icon IconWithSecondaryColor smoke-test 1`] = `
<div class="flex items-center justify-center p-16 gap-24">
<svg class="text-active-orange "
style="width: 1.5rem; height: 1.5rem; --ui-icon-secondary-color: white;"
>
<use xlink:href="#sprite-icon-gui-check-circled-fill">
</use>
</svg>
<svg class="text-active-orange "
style="width: 1.5rem; height: 1.5rem; --ui-icon-secondary-color: var(--color-neutral-1300);"
>
<use xlink:href="#sprite-icon-gui-check-circled-fill">
</use>
</svg>
</div>
`;

exports[`JS Components/Icon Other smoke-test 1`] = `
<div class="grid grid-cols-2 sm:grid-cols-4 ui-grid-gap max-w-screen-lg mb-64">
<div class="border p-16 flex flex-col sm:flex-row items-center justify-between gap-12">
Expand Down
4 changes: 4 additions & 0 deletions src/core/Icon/secondary-colors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export const defaultIconSecondaryColor = (name: string) =>
({
"icon-gui-check-circled-fill": "white",
})[name];
63 changes: 63 additions & 0 deletions src/core/ProductTile.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import React from "react";
import Icon from "./Icon";
import FeaturedLink from "./FeaturedLink";
import { ProductName, products } from "./ProductTile/data";

type ProductTileProps = {
name: ProductName;
selected?: boolean;
currentPage?: boolean;
};

const ProductTile = ({ name, selected, currentPage }: ProductTileProps) => {
const { icon, label, description, link, unavailable } = products[name] ?? {};

return (
<div
className={`rounded-lg p-12 flex flex-col gap-8 transition-colors ${selected ? "bg-neutral-300" : "bg-neutral-1200 hover:bg-neutral-1100"}`}
>
<div className="flex gap-12">
{icon ? <Icon name={icon} size="48" /> : null}
<div
className={`flex ${unavailable ? "flex-row items-center gap-4" : "flex-col justify-center"} `}
>
<p
className={`${unavailable ? "ui-text-p2" : "ui-text-p3"} ${selected ? "text-neutral-800" : "text-neutral-500"} font-medium`}
>
Ably{" "}
</p>
<p
className={`ui-text-p2 ${selected ? "text-neutral-1300" : "text-neutral-300"} font-bold ${unavailable ? "" : "mt-[-3px]"}`}
>
{label}
</p>
</div>
</div>
{unavailable ? (
<div className="-mt-8">
<div className="table-cell bg-neutral-1000 rounded-full px-6 py-2 text-neutral-600 tracking-tighten-0.015 font-bold text-[8px] leading-snug">
COMING SOON
</div>
</div>
) : null}
<p
className={`ui-text-p3 ${selected ? "text-neutral-1000" : "text-neutral-700"} font-medium leading-snug`}
>
{description}
</p>
{selected && link ? (
<FeaturedLink
additionalCSS={`ui-btn-secondary w-full hover:text-neutral-1300 mt-8 text-center inline-block ${
selected ? "text-neutral-1300" : "text-white"
}`}
iconColor="text-orange-600"
url={link}
>
{currentPage ? "View docs" : "Explore"}
</FeaturedLink>
) : null}
</div>
);
};

export default ProductTile;
49 changes: 49 additions & 0 deletions src/core/ProductTile/ProductTile.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import React from "react";
import ProductTile from "../ProductTile";
import { ProductName, products } from "../ProductTile/data";

export default {
title: "JS Components/Product Tile",
component: ProductTile,
tags: ["autodocs"],
};

export const ProductTiles = {
render: () => (
<div className="grid sm:grid-cols-3 gap-32">
{Object.keys(products).map((product) => (
<ProductTile key={product} name={product as ProductName} />
))}
</div>
),
parameters: {
docs: {
description: {
story: "Example usage: `<ProductTile name='pubsub' />`",
},
},
},
};

export const SelectedProductTiles = {
render: () => (
<div className="grid grid-cols-3 gap-32">
{Object.keys(products).map((product, index) => (
<ProductTile
key={product}
name={product as ProductName}
selected={index % 2 === 0}
currentPage={index === 0}
/>
))}
</div>
),
parameters: {
docs: {
description: {
story:
"Demonstration of the odd tiles being 'selected'. The first tile is also marked as the `currentPage` (to simulate being on the Pubsub page), which alters the language of the CTA.",
},
},
},
};
Loading

0 comments on commit 4f7732e

Please sign in to comment.