Skip to content

Commit

Permalink
Merge branch 'develop' into feature/DES-488-hero-image
Browse files Browse the repository at this point in the history
# Conflicts:
#	packages/css/src/components/index.scss
#	packages/react/src/index.ts
  • Loading branch information
VincentSmedinga committed Dec 14, 2023
2 parents a782f1b + d399454 commit b93fe49
Show file tree
Hide file tree
Showing 11 changed files with 132 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/css/src/components/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

/* Append here */
@import "./hero-image/hero-image";
@import "./mark/mark";
@import "./text-input/text-input";
@import "./search-field/search-field";
@import "./logo/logo";
Expand Down
18 changes: 18 additions & 0 deletions packages/css/src/components/mark/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +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.
8 changes: 8 additions & 0 deletions packages/css/src/components/mark/mark.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* @license EUPL-1.2+
* Copyright (c) 2023 Gemeente Amsterdam
*/

.amsterdam-mark {
background-color: var(--amsterdam-mark-background-color);
}
32 changes: 32 additions & 0 deletions packages/react/src/Mark/Mark.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { render } from '@testing-library/react'
import { createRef } from 'react'
import { Mark } from './Mark'
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('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)
})
})
17 changes: 17 additions & 0 deletions packages/react/src/Mark/Mark.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* @license EUPL-1.2+
* Copyright (c) 2023 Gemeente Amsterdam
*/

import clsx from 'clsx'
import { ForwardedRef, forwardRef, HTMLAttributes, PropsWithChildren } from 'react'

export interface MarkProps extends PropsWithChildren<HTMLAttributes<HTMLElement>> {}

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

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

[Mark documentation](../../../css/src/mark/README.md)
2 changes: 2 additions & 0 deletions packages/react/src/Mark/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { Mark } from './Mark'
export type { MarkProps } from './Mark'
1 change: 1 addition & 0 deletions packages/react/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

/* Append here */
export * from './HeroImage'
export * from './Mark'
export * from './TextInput'
export * from './SearchField'
export * from './Logo'
Expand Down
7 changes: 7 additions & 0 deletions proprietary/tokens/src/components/amsterdam/mark.tokens.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"amsterdam": {
"mark": {
"background-color": { "value": "var(--amsterdam-color-yellow)" }
}
}
}
11 changes: 11 additions & 0 deletions storybook/storybook-react/src/Mark/Mark.docs.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
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>

## Voorbeeld

<Primary />
32 changes: 32 additions & 0 deletions storybook/storybook-react/src/Mark/Mark.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* @license EUPL-1.2+
* Copyright (c) 2023 Gemeente Amsterdam
*/

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

const meta = {
title: 'Text/Mark',
component: Mark,
args: {
children: 'Nieuw component',
},
} satisfies Meta<typeof Mark>

export default meta

type Story = StoryObj<typeof meta>

export const Default: Story = {
args: {
children: 'Wat vinden Amsterdammers belangrijk?',
},
render: ({ children }) => (
<Paragraph>
Daarom organiseren we in 2024 het burgerberaad schone stad, waarin 150 Amsterdammers in gesprek gaan over hoe we
de stad beter schoonhouden. <Mark>{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 b93fe49

Please sign in to comment.