Skip to content

Commit

Permalink
feat!: Disallow blue Spotlight and make purple the default (#1798)
Browse files Browse the repository at this point in the history
Co-authored-by: Aram <[email protected]>
  • Loading branch information
VincentSmedinga and alimpens authored Dec 20, 2024
1 parent 310f595 commit 8d1c266
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 42 deletions.
2 changes: 2 additions & 0 deletions packages/css/src/components/spotlight/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Emphasizes a section on a page through a distinctive background colour.
## Guidelines

- Display the Spotlight at the entire width of the [Screen](/docs/components-layout-screen--docs); do not position it on the [Grid](/docs/components-layout-grid--docs).
- Add a Grid with medium vertical padding inside the Spotlight to add whitespace around the content, even for a single element.
- The default background is purple, but the colours can be chosen freely – they do not convey a meaning or theme in itself.
- Refer to [this overview on Stijlweb](https://amsterdam.nl/stijlweb/basiselementen/kleuren/#PagCls_15671872) to determine whether you can use black or white text on the background colour of your choice.

## Relevant WCAG requirements
Expand Down
12 changes: 4 additions & 8 deletions packages/css/src/components/spotlight/spotlight.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
* Copyright Gemeente Amsterdam
*/

.ams-spotlight--azure {
background-color: var(--ams-spotlight-azure-background-color);
.ams-spotlight {
background-color: var(--ams-spotlight-background-color);
}

.ams-spotlight--blue {
background-color: var(--ams-spotlight-blue-background-color);
.ams-spotlight--azure {
background-color: var(--ams-spotlight-azure-background-color);
}

.ams-spotlight--green {
Expand All @@ -27,10 +27,6 @@
background-color: var(--ams-spotlight-orange-background-color);
}

.ams-spotlight--purple {
background-color: var(--ams-spotlight-purple-background-color);
}

.ams-spotlight--yellow {
background-color: var(--ams-spotlight-yellow-background-color);
}
13 changes: 9 additions & 4 deletions packages/react/src/Spotlight/Spotlight.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
import clsx from 'clsx'
import { forwardRef, HTMLAttributes, PropsWithChildren } from 'react'

export const spotlightColors = ['azure', 'blue', 'green', 'lime', 'magenta', 'orange', 'purple', 'yellow'] as const
const defaultColor = 'purple'
export const spotlightColors = ['azure', 'green', 'lime', 'magenta', 'orange', 'yellow'] as const

type SpotlightColor = (typeof spotlightColors)[number]
type SpotlightColor = (typeof spotlightColors)[number] | typeof defaultColor

export type SpotlightProps = {
/** The HTML element to use. */
Expand All @@ -18,8 +19,12 @@ export type SpotlightProps = {
} & PropsWithChildren<HTMLAttributes<HTMLElement>>

export const Spotlight = forwardRef(
({ children, className, as: Tag = 'div', color = 'blue', ...restProps }: SpotlightProps, ref: any) => (
<Tag {...restProps} ref={ref} className={clsx('ams-spotlight', `ams-spotlight--${color}`, className)}>
({ as: Tag = 'div', children, className, color = defaultColor, ...restProps }: SpotlightProps, ref: any) => (
<Tag
{...restProps}
ref={ref}
className={clsx('ams-spotlight', color !== defaultColor && `ams-spotlight--${color}`, className)}
>
{children}
</Tag>
),
Expand Down
7 changes: 1 addition & 6 deletions proprietary/tokens/src/components/ams/spotlight.tokens.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
{
"ams": {
"spotlight": {
"background-color": { "value": "{ams.brand.color.purple.60}" },
"azure": {
"background-color": { "value": "{ams.brand.color.azure.60}" }
},
"blue": {
"background-color": { "value": "{ams.brand.color.blue.60}" }
},
"green": {
"background-color": { "value": "{ams.brand.color.green.60}" }
},
Expand All @@ -19,9 +17,6 @@
"orange": {
"background-color": { "value": "{ams.brand.color.orange.60}" }
},
"purple": {
"background-color": { "value": "{ams.brand.color.purple.60}" }
},
"yellow": {
"background-color": { "value": "{ams.brand.color.yellow.60}" }
}
Expand Down
4 changes: 2 additions & 2 deletions storybook/src/components/Breakout/Breakout.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const Default: Story = {
args: {
children: [
<Breakout.Cell colSpan="all" has="spotlight" key={1} rowSpan={{ medium: 2, narrow: 2, wide: 1 }} rowStart={2}>
<Spotlight />
<Spotlight color="green" />
</Breakout.Cell>,
<Breakout.Cell
colSpan={{ medium: 8, narrow: 4, wide: 6 }}
Expand Down Expand Up @@ -57,7 +57,7 @@ export const VerticalLayout: Story = {
args: {
children: [
<Breakout.Cell colSpan="all" has="spotlight" key={1} rowSpan={2} rowStart={2}>
<Spotlight />
<Spotlight color="orange" />
</Breakout.Cell>,
<Breakout.Cell colSpan="all" has="figure" key={2} rowSpan={2} rowStart={1}>
<Image alt="" src="https://picsum.photos/1600/900" />
Expand Down
8 changes: 0 additions & 8 deletions storybook/src/components/Spotlight/Spotlight.docs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ import README from "../../../../packages/css/src/components/spotlight/README.md?

<Canvas of={SpotlightStories.Azure} />

### Blue

<Canvas of={SpotlightStories.Blue} />

### Green

<Canvas of={SpotlightStories.Green} />
Expand All @@ -38,10 +34,6 @@ import README from "../../../../packages/css/src/components/spotlight/README.md?

<Canvas of={SpotlightStories.Orange} />

### Purple

<Canvas of={SpotlightStories.Purple} />

### Yellow

<Canvas of={SpotlightStories.Yellow} />
Expand Down
12 changes: 0 additions & 12 deletions storybook/src/components/Spotlight/Spotlight.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,6 @@ export const Azure: Story = {
},
}

export const Blue: Story = {
args: {
color: 'blue',
},
}

export const Green: Story = {
args: {
color: 'green',
Expand All @@ -66,12 +60,6 @@ export const Orange: Story = {
},
}

export const Purple: Story = {
args: {
color: 'purple',
},
}

export const Yellow: Story = {
args: {
color: 'yellow',
Expand Down
2 changes: 1 addition & 1 deletion storybook/src/pages/amsterdam/ArticlePage/ArticleBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const ArticleBody = ({ lead, paragraph1, spotlightHeading, spotlightLinkL
<Paragraph>{paragraph1}</Paragraph>
</Grid.Cell>
</Grid>
<Spotlight as="section" color="purple">
<Spotlight as="section">
<Grid paddingTop="medium" paddingBottom="large">
<Grid.Cell span={{ narrow: 4, medium: 6, wide: 8 }} start={{ narrow: 1, medium: 2, wide: 3 }}>
<Column gap="small">
Expand Down
2 changes: 1 addition & 1 deletion storybook/src/pages/amsterdam/HomePage/HomeSpotlight.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Grid, Heading, Link, Paragraph, Spotlight } from '@amsterdam/design-system-react'

export const HomeSpotlight = () => (
<Spotlight color="purple">
<Spotlight>
<Grid paddingVertical="medium">
<Grid.Cell span={{ narrow: 4, medium: 4, wide: 6 }}>
<Heading className="ams-mb--xs" inverseColor size="level-2">
Expand Down

0 comments on commit 8d1c266

Please sign in to comment.