feat(core): add chip component (#2225)

This commit is contained in:
Rémi Doreau
2020-09-07 09:45:47 +02:00
committed by GitHub
parent 9c76103ebd
commit 8b43c483b2
2 changed files with 77 additions and 0 deletions
@@ -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 = () => (
<Chip label="Default" />
);
export const LargeDeletable = () => (
<Chip
label="Large deletable"
size="medium"
onDelete={() => ({})}
/>
);
export const LargeNotDeletable = () => (
<Chip
label="Large not deletable"
size="medium"
/>
);
export const SmallDeletable = () => (
<Chip
label="Small deletable"
size="small"
onDelete={() => ({})}
/>
);
export const SmallNotDeletable = () => (
<Chip
label="Small not deletable"
size="small"
/>
);
+21
View File
@@ -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: {