Skip to content

Commit

Permalink
Rename ‘Highlight’ component to ‘Spotlight’
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentSmedinga committed Dec 12, 2023
1 parent a480e39 commit 9d11521
Show file tree
Hide file tree
Showing 19 changed files with 115 additions and 115 deletions.
2 changes: 1 addition & 1 deletion packages/css/src/components/grid/README.grid.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Levert een tweedimensionaal raster waarop alle elementen van een pagina uitgelij

Elke pagina moet het grid gebruiken als basis voor de layout, dus direct binnen [Screen](?path=/docs/layout-screen--docs).

Een [Footer](?path=/docs/react_containers-footer--docs) en een [Highlight](?path=/docs/react_containers-highlight--docs) zijn iets breder dan het grid.
Een [Footer](?path=/docs/react_containers-footer--docs) en een [Spotlight](?path=/docs/react_containers-spotlight--docs) zijn iets breder dan het grid.
Daarom wordt in HTML vóór deze componenten een instantie van Grid afgesloten en erbinnen een nieuwe geopend.

Meerdere instanties van dit component zijn dus mogelijk op een pagina.
Expand Down
36 changes: 0 additions & 36 deletions packages/css/src/components/highlight/highlight.scss

This file was deleted.

2 changes: 1 addition & 1 deletion packages/css/src/components/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
@import "./grid/grid";
@import "./grid/grid-cell";
@import "./heading/heading";
@import "./highlight/highlight";
@import "./spotlight/spotlight";
@import "./icon/icon";
@import "./link/link";
@import "./ordered-list/ordered-list";
Expand Down
2 changes: 1 addition & 1 deletion packages/css/src/components/screen/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Daarbinnen combineer je componenten als
[Grid](?path=/docs/react_layout-grid--docs),
Header,
[Footer](?path=/docs/react_containers-footer--docs),
[Highlight](?path=/docs/react_containers-highlight--docs)
[Spotlight](?path=/docs/react_containers-spotlight--docs)
en Figure.

## Ontwerp
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Highlight
# Spotlight

Benadrukt een sectie op een pagina middels een opvallende achtergrondkleur.

Expand Down
36 changes: 36 additions & 0 deletions packages/css/src/components/spotlight/spotlight.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* @license EUPL-1.2+
* Copyright (c) 2023 Gemeente Amsterdam
*/

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

.amsterdam-spotlight--dark-green {
background-color: var(--amsterdam-spotlight-dark-green-background-color);
}

.amsterdam-spotlight--green {
background-color: var(--amsterdam-spotlight-green-background-color);
}

.amsterdam-spotlight--light-blue {
background-color: var(--amsterdam-spotlight-light-blue-background-color);
}

.amsterdam-spotlight--magenta {
background-color: var(--amsterdam-spotlight-magenta-background-color);
}

.amsterdam-spotlight--orange {
background-color: var(--amsterdam-spotlight-orange-background-color);
}

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

.amsterdam-spotlight--yellow {
background-color: var(--amsterdam-spotlight-yellow-background-color);
}
6 changes: 3 additions & 3 deletions packages/react/src/Footer/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ import {
PropsWithChildren,
RefAttributes,
} from 'react'
import { Highlight } from '../Highlight/Highlight'
import { Spotlight } from '../Spotlight/Spotlight'

export const FooterTop = forwardRef(
(
{ children, className, ...restProps }: PropsWithChildren<HTMLAttributes<HTMLDivElement>>,
ref: ForwardedRef<HTMLDivElement>,
) => (
<Highlight {...restProps} color="blue" ref={ref} className={clsx('amsterdam-footer__top', className)}>
<Spotlight {...restProps} color="blue" ref={ref} className={clsx('amsterdam-footer__top', className)}>
{children}
</Highlight>
</Spotlight>
),
)

Expand Down
3 changes: 0 additions & 3 deletions packages/react/src/Highlight/README.md

This file was deleted.

2 changes: 0 additions & 2 deletions packages/react/src/Highlight/index.ts

This file was deleted.

3 changes: 3 additions & 0 deletions packages/react/src/Spotlight/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# React Spotlight component

[Spotlight documentation](../../../css/src/spotlight/README.md)
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { render } from '@testing-library/react'
import { createRef } from 'react'
import { Highlight } from './Highlight'
import { Spotlight } from './Spotlight'
import '@testing-library/jest-dom'

describe('Highlight', () => {
describe('Spotlight', () => {
it('renders', () => {
const { container } = render(<Highlight />)
const { container } = render(<Spotlight />)

const component = container.querySelector(':only-child')

Expand All @@ -14,38 +14,38 @@ describe('Highlight', () => {
})

it('renders a design system BEM class name', () => {
const { container } = render(<Highlight />)
const { container } = render(<Spotlight />)

const component = container.querySelector(':only-child')

expect(component).toHaveClass('amsterdam-highlight')
expect(component).toHaveClass('amsterdam-spotlight')
})

it('renders an additional class name', () => {
const { container } = render(<Highlight className="extra" />)
const { container } = render(<Spotlight className="extra" />)

const component = container.querySelector(':only-child')

expect(component).toHaveClass('extra')

expect(component).toHaveClass('amsterdam-highlight')
expect(component).toHaveClass('amsterdam-spotlight')
})

it('supports ForwardRef in React', () => {
const ref = createRef<HTMLDivElement>()

const { container } = render(<Highlight ref={ref} />)
const { container } = render(<Spotlight ref={ref} />)

const component = container.querySelector(':only-child')

expect(ref.current).toBe(component)
})

it('gets a color class if you set a color', () => {
const { container } = render(<Highlight color="green" />)
const { container } = render(<Spotlight color="green" />)

const component = container.querySelector(':only-child')

expect(component).toHaveClass('amsterdam-highlight--green')
expect(component).toHaveClass('amsterdam-spotlight--green')
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,25 @@
import clsx from 'clsx'
import { forwardRef, HTMLAttributes, PropsWithChildren } from 'react'

export interface HighlightProps extends PropsWithChildren<HTMLAttributes<HTMLElement>> {
export interface SpotlightProps extends PropsWithChildren<HTMLAttributes<HTMLElement>> {
as?: 'article' | 'aside' | 'div' | 'footer' | 'section'
color?: 'blue' | 'dark-green' | 'green' | 'light-blue' | 'magenta' | 'orange' | 'purple' | 'yellow'
}

export const Highlight = forwardRef<HTMLDivElement, HighlightProps>(
({ children, className, as = 'div', color = 'blue', ...restProps }: HighlightProps, ref) => {
export const Spotlight = forwardRef<HTMLDivElement, SpotlightProps>(
({ children, className, as = 'div', color = 'blue', ...restProps }: SpotlightProps, ref) => {
const Component = as

return (
<Component
{...restProps}
ref={ref}
className={clsx('amsterdam-highlight', `amsterdam-highlight--${color}`, className)}
className={clsx('amsterdam-spotlight', `amsterdam-spotlight--${color}`, className)}
>
{children}
</Component>
)
},
)

Highlight.displayName = 'Highlight'
Spotlight.displayName = 'Spotlight'
2 changes: 2 additions & 0 deletions packages/react/src/Spotlight/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { Spotlight } from './Spotlight'
export type { SpotlightProps } from './Spotlight'
2 changes: 1 addition & 1 deletion packages/react/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export * from './Image'
export * from './Pagination'
export * from './Screen'
export * from './Switch'
export * from './Highlight'
export * from './Spotlight'
export * from './Card'
export * from './Alert'
export * from './AspectRatio'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"amsterdam": {
"highlight": {
"spotlight": {
"blue": {
"background-color": { "value": "{amsterdam.color.primary-blue}" }
},
Expand Down
2 changes: 1 addition & 1 deletion storybook/storybook-react/src/Grid/Grid.docs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Daarom bestaat er een compacte variant van het grid.
In tegenstelling tot de horizontale marges zijn de verticale instelbaar.
De opties `paddingVertical`, `paddingTop` en `paddingBottom` voegen witruimte boven en/of onder het grid toe.
Dit is handig in een vlak met een achtergrondkleur zoals [Footer](?path=/docs/react_containers-footer--docs) of
[Highlight](?path=/docs/react_containers-highlight--docs) of tussen twee opvolgende grids.
[Spotlight](?path=/docs/react_containers-spotlight--docs) of tussen twee opvolgende grids.

Elk kan een waarde `medium`, `small` of `large` krijgen.
De witruimtes zijn even breed als de horizontale witruimte tussen de kolommen,
Expand Down
43 changes: 0 additions & 43 deletions storybook/storybook-react/src/Highlight/Highlight.docs.mdx

This file was deleted.

43 changes: 43 additions & 0 deletions storybook/storybook-react/src/Spotlight/Spotlight.docs.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { Canvas, Controls, Markdown, Meta, Primary } from "@storybook/blocks";
import * as SpotlightStories from "./Spotlight.stories.tsx";
import README from "../../../../packages/css/src/components/spotlight/README.md?raw";

<Meta of={SpotlightStories} />

<Markdown>{README}</Markdown>

<Primary />

<Controls />

### Blauw

<Canvas of={SpotlightStories.Blue} />

### Donkergroen

<Canvas of={SpotlightStories.DarkGreen} />

### Geel

<Canvas of={SpotlightStories.Yellow} />

### Groen

<Canvas of={SpotlightStories.Green} />

### Lichtblauw

<Canvas of={SpotlightStories.LightBlue} />

### Magenta

<Canvas of={SpotlightStories.Magenta} />

### Oranje

<Canvas of={SpotlightStories.Orange} />

### Paars

<Canvas of={SpotlightStories.Purple} />
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
* Copyright (c) 2023 Gemeente Amsterdam
*/

import { Blockquote, Grid, Highlight } from '@amsterdam/design-system-react'
import { Blockquote, Grid, Spotlight } from '@amsterdam/design-system-react'
import { Meta, StoryObj } from '@storybook/react'
import { exampleQuote } from '../shared/exampleContent'

const meta = {
title: 'Containers/Highlight',
component: Highlight,
title: 'Containers/Spotlight',
component: Spotlight,
argTypes: {
color: {
options: ['blue', 'dark-green', 'green', 'light-blue', 'magenta', 'orange', 'purple', 'yellow'],
Expand All @@ -34,15 +34,15 @@ const meta = {
},
},
render: ({ color }) => (
<Highlight color={color}>
<Spotlight color={color}>
<Grid paddingVertical="medium">
<Grid.Cell fullWidth>
<Blockquote inverseColor={!color || !['green', 'yellow'].includes(color)}>{exampleQuote()}</Blockquote>
</Grid.Cell>
</Grid>
</Highlight>
</Spotlight>
),
} satisfies Meta<typeof Highlight>
} satisfies Meta<typeof Spotlight>

export default meta

Expand Down

0 comments on commit 9d11521

Please sign in to comment.