Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Button typescript #675

Merged
merged 2 commits into from
Oct 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libraries/core-react/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module.exports = {
verbose: true,
setupFilesAfterEnv: ['./rtl.setup.ts'],
transform: {
'.js': 'babel-jest',
'.(js)': 'babel-jest',
'.(ts|tsx)': 'ts-jest',
},
testRegex: '(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$',
Expand Down
193 changes: 0 additions & 193 deletions libraries/core-react/src/Button/Button.jsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import '@testing-library/jest-dom'
import 'jest-styled-components'
import styled from 'styled-components'
import { save } from '@equinor/eds-icons'
import { Button, Icon } from '..'
import { Button } from './Button'
import { Icon } from '../Icon'

Icon.add({ save })

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
// @ts-nocheck
import primary from '@equinor/eds-tokens/components/button/buttons-primary.json'
import secondary from '@equinor/eds-tokens/components/button/buttons-secondary.json'
import danger from '@equinor/eds-tokens/components/button/buttons-danger.json'
import disabled from '@equinor/eds-tokens/components/button/buttons-disabled.json'
import type {
Border,
Focus,
Hover,
Spacing,
Typography,
} from '@equinor/eds-tokens'

const colors = {
primary: {
Expand Down Expand Up @@ -35,7 +41,41 @@ const colors = {
},
}

export const button = {
export type Button = {
height: string
width?: string
background: string
color: string
border: Border
typography: Typography
spacing?: Partial<Spacing>
focus?: Focus
hover?: Hover
// TODO Remove these once figma-broker is updated with proper types
pressedColor?: string
clickboundOffset?: number | string
clickbound?: string
}

type Buttons = {
[P in keyof typeof colors]: {
[P2 in keyof typeof colors[P]]: Button
}
}

export type ButtonGroups =
| Buttons['primary']
| Buttons['secondary']
| Buttons['danger']
| Buttons['disabled']

export const button: {
colors: Buttons
icon_size: {
width: string
height: string
}
} = {
colors,
icon_size: {
width: '24px',
Expand Down
Loading