From 8b43c483b297c9bff4b9b1ff45100112bce79cf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Doreau?= <32459935+ayshiff@users.noreply.github.com> Date: Mon, 7 Sep 2020 09:45:47 +0200 Subject: [PATCH] feat(core): add chip component (#2225) --- .../src/components/stories/Chip.stories.tsx | 56 +++++++++++++++++++ packages/theme/src/baseTheme.ts | 21 +++++++ 2 files changed, 77 insertions(+) create mode 100644 packages/core/src/components/stories/Chip.stories.tsx diff --git a/packages/core/src/components/stories/Chip.stories.tsx b/packages/core/src/components/stories/Chip.stories.tsx new file mode 100644 index 0000000000..29170214a2 --- /dev/null +++ b/packages/core/src/components/stories/Chip.stories.tsx @@ -0,0 +1,56 @@ +/* + * Copyright 2020 Spotify AB + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import React from 'react'; +import { Chip } from '@material-ui/core'; + +export default { + title: 'Chip', + component: Chip, +}; + +export const Default = () => ( + +); + +export const LargeDeletable = () => ( + ({})} + /> +); + +export const LargeNotDeletable = () => ( + +); + +export const SmallDeletable = () => ( + ({})} + /> +); + +export const SmallNotDeletable = () => ( + +); diff --git a/packages/theme/src/baseTheme.ts b/packages/theme/src/baseTheme.ts index dc68db11d6..00a485bb41 100644 --- a/packages/theme/src/baseTheme.ts +++ b/packages/theme/src/baseTheme.ts @@ -192,10 +192,31 @@ export function createThemeOverrides(theme: BackstageTheme): Overrides { }, MuiChip: { root: { + backgroundColor: '#D9D9D9', // By default there's no margin, but it's usually wanted, so we add some trailing margin marginRight: theme.spacing(1), marginBottom: theme.spacing(1), }, + label: { + color: theme.palette.grey[900], + lineHeight: `${theme.spacing(2.5)}px`, + fontWeight: theme.typography.fontWeightMedium, + fontSize: `${theme.spacing(1.75)}px`, + }, + labelSmall: { + fontSize: `${theme.spacing(1.5)}px`, + }, + deleteIcon: { + color: theme.palette.grey[500], + width: `${theme.spacing(3)}px`, + height: `${theme.spacing(3)}px`, + margin: `0 ${theme.spacing(0.75)}px 0 -${theme.spacing(0.75)}px`, + }, + deleteIconSmall: { + width: `${theme.spacing(2)}px`, + height: `${theme.spacing(2)}px`, + margin: `0 ${theme.spacing(0.5)}px 0 -${theme.spacing(0.5)}px`, + }, }, MuiCardHeader: { root: {