Skip to content

Commit

Permalink
Implement mark component
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentSmedinga committed Dec 12, 2023
1 parent 9f9bb1e commit 4228771
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 22 deletions.
17 changes: 17 additions & 0 deletions packages/css/src/components/mark/README.md
Original file line number Diff line number Diff line change
@@ -1 +1,18 @@
# Mark

Markeert een fragment tekst met een gele achtergrond.
Het zorgt voor sterke nadruk op de tekst en leidt de aandacht ernaartoe.

## Richtlijnen

### Zo gebruiken

- Maximaal 1 markering per pagina.
De voorkeur is geen markering.
- Maximaal 1 zin.

### Dit vermijden

- Niet in de titel en subtitels gebruiken.
Zorg voor een belangrijke, pakkende titel als de hele paragraaf belangrijk is.
- Mag niet voor een hele paragraaf gebruikt worden.
2 changes: 1 addition & 1 deletion packages/css/src/components/mark/mark.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
*/

.amsterdam-mark {
/* Add styles here */
background-color: var(--amsterdam-mark-background-color);
}
13 changes: 1 addition & 12 deletions packages/react/src/Mark/Mark.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,27 @@ import '@testing-library/jest-dom'
describe('Mark', () => {
it('renders', () => {
const { container } = render(<Mark />)

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

expect(component).toBeInTheDocument()
expect(component).toBeVisible()
})

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

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

expect(component).toHaveClass('amsterdam-mark')
})

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

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

expect(component).toHaveClass('extra')

expect(component).toHaveClass('amsterdam-mark')
expect(component).toHaveClass('amsterdam-mark extra')
})

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

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

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

expect(ref.current).toBe(component)
})
})
4 changes: 2 additions & 2 deletions packages/react/src/Mark/Mark.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import { ForwardedRef, forwardRef, HTMLAttributes, PropsWithChildren } from 'rea
export interface MarkProps extends PropsWithChildren<HTMLAttributes<HTMLElement>> {}

export const Mark = forwardRef(({ children, className, ...restProps }: MarkProps, ref: ForwardedRef<HTMLElement>) => (
<span {...restProps} ref={ref} className={clsx('amsterdam-mark', className)}>
<mark {...restProps} ref={ref} className={clsx('amsterdam-mark', className)}>
{children}
</span>
</mark>
))

Mark.displayName = 'Mark'
4 changes: 3 additions & 1 deletion proprietary/tokens/src/components/amsterdam/mark.tokens.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"amsterdam": {
"mark": {}
"mark": {
"background-color": { "value": "var(--amsterdam-color-yellow)" }
}
}
}
6 changes: 3 additions & 3 deletions storybook/storybook-react/src/Mark/Mark.docs.mdx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Controls, Markdown, Meta, Primary } from "@storybook/blocks";
import { Markdown, Meta, Primary } from "@storybook/blocks";
import * as MarkStories from "./Mark.stories.tsx";
import README from "../../../../packages/css/src/components/mark/README.md?raw";

<Meta of={MarkStories} />

<Markdown>{README}</Markdown>

<Primary />
## Voorbeeld

<Controls />
<Primary />
17 changes: 14 additions & 3 deletions storybook/storybook-react/src/Mark/Mark.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
* Copyright (c) 2023 Gemeente Amsterdam
*/

import { Mark } from '@amsterdam/design-system-react'
import { Mark, Paragraph } from '@amsterdam/design-system-react'
import { Meta, StoryObj } from '@storybook/react'

const meta = {
title: 'Mark',
title: 'Text/Mark',
component: Mark,
args: {
children: 'Nieuw component',
Expand All @@ -18,4 +18,15 @@ export default meta

type Story = StoryObj<typeof meta>

export const Default: Story = {}
export const Default: Story = {
args: {
children: 'Wat vinden Amsterdammers belangrijk?',
},
render: (args) => (
<Paragraph>
Daarom organiseren we in 2024 het burgerberaad schone stad, waarin 150 Amsterdammers in gesprek gaan over hoe we
de stad beter schoonhouden. <Mark>{args.children}</Mark> Welke oplossingen zien zij? Hier zijn we benieuwd naar.
Want elke Amsterdammer heeft afval en moet het kwijt. Wij kunnen als gemeente veel van deze afvalexperts leren.
</Paragraph>
),
}

0 comments on commit 4228771

Please sign in to comment.