From d88972ba169fefe7a40dd335b27de5fa80a47e11 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Mon, 13 Jan 2025 15:21:13 +0100 Subject: [PATCH] style: allow customization of system 'Banner' icons through CSS variables (#858) * style: allow customization of system 'Banner' icons through CSS variables * chore: bump version to 27.1.0 --- CHANGELOG.md | 4 ++++ package-lock.json | 4 ++-- package.json | 2 +- src/icons/banner-icon.module.css | 32 ++++++++++++++++++++++++++++++++ src/icons/banner-icon.tsx | 18 +++++++++++------- 5 files changed, 50 insertions(+), 10 deletions(-) create mode 100644 src/icons/banner-icon.module.css diff --git a/CHANGELOG.md b/CHANGELOG.md index b7fbcf1f..45e496f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ Reactist follows [semantic versioning](https://semver.org/) and doesn't introduce breaking changes (API-wise) in minor or patch releases. However, the appearance of a component might change in a minor or patch release so keep an eye on redesigns and make sure your app still looks and feels like you expect it. +# 27.1.0 + +- [Feat] Expose CSS variables for customizng the icon color of the `Banner` component system types. + # 27.0.1 - [Docs] Document the `maxLength` prop for the `TextField` component. diff --git a/package-lock.json b/package-lock.json index aa5bcc06..fc5d2107 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@doist/reactist", - "version": "27.0.1", + "version": "27.1.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@doist/reactist", - "version": "27.0.1", + "version": "27.1.0", "hasInstallScript": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index da5b60de..d29bc3bb 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "email": "henning@doist.com", "url": "http://doist.com" }, - "version": "27.0.1", + "version": "27.1.0", "license": "MIT", "homepage": "https://github.com/Doist/reactist#readme", "repository": { diff --git a/src/icons/banner-icon.module.css b/src/icons/banner-icon.module.css new file mode 100644 index 00000000..216ab064 --- /dev/null +++ b/src/icons/banner-icon.module.css @@ -0,0 +1,32 @@ +:root { + --reactist-banner-info-icon-color: #316fea; + --reactist-banner-upgrade-icon-color: #f48318; + --reactist-banner-experiment-icon-color: #f48318; + --reactist-banner-warning-icon-color: #eb8909; + --reactist-banner-error-icon-color: #dc4c3e; + --reactist-banner-success-icon-color: #058527; +} + +.info { + color: var(--reactist-banner-info-icon-color); +} + +.upgrade { + color: var(--reactist-banner-upgrade-icon-color); +} + +.experiment { + color: var(--reactist-banner-experiment-icon-color); +} + +.warning { + color: var(--reactist-banner-warning-icon-color); +} + +.error { + color: var(--reactist-banner-error-icon-color); +} + +.success { + color: var(--reactist-banner-success-icon-color); +} diff --git a/src/icons/banner-icon.tsx b/src/icons/banner-icon.tsx index b0f6ed56..0b55f639 100644 --- a/src/icons/banner-icon.tsx +++ b/src/icons/banner-icon.tsx @@ -1,6 +1,8 @@ import * as React from 'react' import type { SystemBannerType } from '../banner/banner' +import styles from './banner-icon.module.css' + const bannerIconForType: Record = { info: BannerInfoIcon, upgrade: BannerUpgradeIcon, @@ -12,14 +14,16 @@ const bannerIconForType: Record = { function BannerIcon({ type, ...props }: JSX.IntrinsicElements['svg'] & { type: SystemBannerType }) { const Icon = bannerIconForType[type] - return Icon ? : null + return Icon ? ( + + ) : null } function BannerInfoIcon(props: JSX.IntrinsicElements['svg']) { return (