Skip to content

Commit

Permalink
Removed utrecht and restored style and functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
dlnr committed Jan 30, 2024
1 parent 8974163 commit 8f15539
Show file tree
Hide file tree
Showing 11 changed files with 183 additions and 301 deletions.
71 changes: 64 additions & 7 deletions packages/css/src/components/button/button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,73 @@

@import "../../../node_modules/@utrecht/components/button/css";

@mixin reset {
-webkit-text-size-adjust: 100%;
}

.amsterdam-button {
@mixin amsterdam-button {
border: none;
cursor: var(--amsterdam-action-activate-cursor, revert);
display: inline-flex;
font-family: var(--amsterdam-button-font-family);
font-size: var(--amsterdam-button-spacious-font-size);
gap: var(--amsterdam-button-gap);
line-height: var(--amsterdam-button-spacious-line-height);

@include reset;
outline-offset: var(--amsterdam-button-outline-offset);
padding-block: var(--amsterdam-button-padding-block-start) var(--amsterdam-button-padding-block-end);
padding-inline: var(--amsterdam-button-padding-inline-start) var(--amsterdam-button-padding-inline-end);
-webkit-text-size-adjust: 100%;

.amsterdam-theme--compact & {
font-size: var(--amsterdam-breadcrumb-compact-font-size);
line-height: var(--amsterdam-breadcrumb-compact-line-height);
}

&--busy {
cursor: var(--amsterdam-action-busy-cursor, revert);
}

&:disabled,
&[aria-disabled="true"] {
cursor: var(--amsterdam-action-disabled-cursor, revert);
}

&:hover:not(:disabled, [aria-disabled="true"]) {
cursor: var(--amsterdam-action-hover-cursor, pointer);
}

@media screen and (forced-colors: active) {
background-color: ButtonFace;
border: 2px solid buttonborder;
color: ButtonText;
}
}

.amsterdam-button--primary {
@include amsterdam-button;

background-color: var(--amsterdam-button-primary-background-color);
color: var(--amsterdam-button-primary-color);

&:disabled,
[aria-disabled="true"] {
background-color: var(--amsterdam-button-primary-disabled-background-color);
cursor: var(--amsterdam-action-disabled-cursor, revert);
}

&:hover:not(:disabled, [aria-disabled="true"]) {
background-color: var(--amsterdam-button-primary-hover-background-color);
}
}

.amsterdam-button--secondary {
@include amsterdam-button;

background-color: var(--amsterdam-button-secondary-background-color);
box-shadow: var(--amsterdam-button-secondary-box-shadow);
color: var(--amsterdam-button-secondary-color);

&:disabled,
[aria-disabled="true"] {
background-color: var(--amsterdam-button-secondary-disabled-background-color);
box-shadow: var(--amsterdam-button-secondary-disabled-box-shadow);
color: var(--amsterdam-button-secondary-disabled-color);
}

&:hover:not(:disabled, [aria-disabled="true"]) {
Expand All @@ -39,8 +84,20 @@
}

.amsterdam-button--tertiary {
@include amsterdam-button;

background-color: var(--amsterdam-button-tertiary-background-color);
color: var(--amsterdam-button-tertiary-color);

&:disabled,
[aria-disabled="true"] {
background-color: var(--amsterdam-button-tertiary-disabled-background-color);
color: var(--amsterdam-button-tertiary-disabled-color);
}

&:hover:not(:disabled, [aria-disabled="true"]) {
box-shadow: var(--amsterdam-button-tertiary-hover-box-shadow);
color: var(--amsterdam-button-tertiary-hover-color);
}
}

Expand Down
1 change: 0 additions & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
],
"dependencies": {
"@amsterdam/design-system-react-icons": "workspace:*",
"@utrecht/component-library-react": "3.0.0",
"clsx": "2.1.0"
},
"devDependencies": {
Expand Down
8 changes: 4 additions & 4 deletions packages/react/src/Button/Button.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('Button', () => {

expect(button).toBeInTheDocument()
expect(button).toHaveAttribute('type', 'button')
expect(button).toHaveClass('utrecht-button--primary-action')
expect(button).toHaveClass('amsterdam-button--primary')
})

it('renders a button with a specified variant', () => {
Expand All @@ -49,11 +49,11 @@ describe('Button', () => {
})

expect(buttonPrimary).toBeInTheDocument()
expect(buttonPrimary).toHaveClass('utrecht-button--primary-action')
expect(buttonPrimary).toHaveClass('amsterdam-button--primary')
expect(buttonSecondary).toBeInTheDocument()
expect(buttonSecondary).toHaveClass('utrecht-button--secondary-action')
expect(buttonSecondary).toHaveClass('amsterdam-button--secondary')
expect(buttonTertiary).toBeInTheDocument()
expect(buttonTertiary).toHaveClass('utrecht-button--subtle')
expect(buttonTertiary).toHaveClass('amsterdam-button--tertiary')
})

it('renders a disabled button with a specified variant', () => {
Expand Down
37 changes: 15 additions & 22 deletions packages/react/src/Button/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,47 +1,40 @@
/**
* @license EUPL-1.2+
* Copyright (c) 2021 Robbert Broersma
* Copyright (c) 2023 Gemeente Amsterdam
* Copyright (c) 2024 Gemeente Amsterdam
*/

import { Button as CommunityButton } from '@utrecht/component-library-react'
import clsx from 'clsx'
import { forwardRef } from 'react'
import type { ButtonHTMLAttributes, ForwardedRef, PropsWithChildren } from 'react'

export type ButtonProps = {
variant?: 'primary' | 'secondary' | 'tertiary'
busy?: boolean
pressed?: boolean
} & PropsWithChildren<ButtonHTMLAttributes<HTMLButtonElement>>

type CommunityButtonAppearance = 'primary-action-button' | 'secondary-action-button' | 'subtle-button'

function getAppearance(variant: ButtonProps['variant']): CommunityButtonAppearance {
switch (variant) {
case 'secondary':
return 'secondary-action-button'
case 'tertiary':
return 'subtle-button'
default:
return 'primary-action-button'
}
}

export const Button = forwardRef(
({ children, disabled, variant = 'primary', ...restProps }: ButtonProps, ref: ForwardedRef<HTMLButtonElement>) => {
(
{ children, type, disabled, busy, pressed, variant = 'primary', ...restProps }: ButtonProps,
ref: ForwardedRef<HTMLButtonElement>,
) => {
return (
<CommunityButton
<button
{...restProps}
appearance={getAppearance(variant)}
ref={ref}
disabled={disabled}
className={clsx(
'amsterdam-button',
variant === 'secondary' && 'amsterdam-button--secondary',
variant === 'tertiary' && 'amsterdam-button--tertiary',
busy === true && 'amsterdam-button--busy',
`amsterdam-button--${variant}`,
pressed === true && 'amsterdam-button--pressed',
)}
type={type || 'button'}
aria-busy={busy || undefined}
aria-pressed={typeof pressed === 'boolean' ? pressed : undefined}
>
{children}
</CommunityButton>
</button>
)
},
)
Expand Down
43 changes: 7 additions & 36 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"utrecht": {
"amsterdam": {
"action": {
"activate": { "cursor": { "value": "pointer" } },
"busy": { "cursor": { "value": "wait" } },
Expand Down
7 changes: 0 additions & 7 deletions proprietary/tokens/src/common/utrecht/focus.tokens.json

This file was deleted.

35 changes: 32 additions & 3 deletions proprietary/tokens/src/components/amsterdam/button.tokens.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
{
"amsterdam": {
"button": {
"font-family": { "value": "{amsterdam.typography.font-family}" },
"gap": { "value": "1rem" },
"padding-inline-start": { "value": "{amsterdam.spacing.inset.md}" },
"padding-inline-end": { "value": "{amsterdam.spacing.inset.md}" },
"padding-block-start": { "value": "{amsterdam.spacing.inset.sm}" },
"padding-block-end": { "value": "{amsterdam.spacing.inset.sm}" },
"outline-offset": { "value": "{amsterdam.focus.outline-offset}" },
"spacious": {
"font-size": { "value": "{amsterdam.typography.spacious.text-level.5.font-size}" },
"line-height": { "value": "{amsterdam.typography.spacious.text-level.5.line-height}" }
Expand All @@ -9,21 +16,43 @@
"font-size": { "value": "{amsterdam.typography.compact.text-level.5.font-size}" },
"line-height": { "value": "{amsterdam.typography.compact.text-level.5.line-height}" }
},
"primary": {
"background-color": { "value": "{amsterdam.color.primary-blue}" },
"color": { "value": "{amsterdam.color.primary-white}" },
"disabled": {
"background-color": { "value": "{amsterdam.color.neutral-grey2}" }
},
"hover": {
"background-color": { "value": "{amsterdam.color.dark-blue}" }
}
},
"secondary": {
"background-color": { "value": "{amsterdam.color.primary-white}" },
"color": { "value": "{amsterdam.color.primary-blue}" },
"box-shadow": { "value": "inset 0 0 0 2px {amsterdam.color.primary-blue}" },
"hover": {
"box-shadow": { "value": "inset 0 0 0 3px {amsterdam.color.dark-blue}" }
"box-shadow": { "value": "inset 0 0 0 3px {amsterdam.color.dark-blue}" },
"color": { "value": "{amsterdam.color.dark-blue}" }
},
"disabled": {
"box-shadow": { "value": "inset 0 0 0 2px {amsterdam.color.neutral-grey2}" }
"background-color": { "value": "{amsterdam.color.primary-white}" },
"box-shadow": { "value": "inset 0 0 0 2px {amsterdam.color.neutral-grey2}" },
"color": { "value": "{amsterdam.color.neutral-grey2}" }
},
"focus": {
"box-shadow": { "value": "inset 0 0 0 2px {amsterdam.color.primary-blue}" }
}
},
"tertiary": {
"background-color": { "value": "transparent" },
"color": { "value": "{amsterdam.color.primary-blue}" },
"hover": {
"box-shadow": { "value": "inset 0 0 0 2px {amsterdam.color.dark-blue}" }
"box-shadow": { "value": "inset 0 0 0 2px {amsterdam.color.dark-blue}" },
"color": { "value": "{amsterdam.color.dark-blue}" }
},
"disabled": {
"background-color": { "value": "transparent" },
"color": { "value": "{amsterdam.color.neutral-grey2}" }
}
}
}
Expand Down
Loading

0 comments on commit 8f15539

Please sign in to comment.