Skip to content

Commit

Permalink
feat(theme): add badge built-in component
Browse files Browse the repository at this point in the history
  • Loading branch information
PeachScript committed Apr 6, 2020
1 parent 0a8cb01 commit 880ab27
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
31 changes: 31 additions & 0 deletions packages/preset-dumi/src/themes/default/builtins/Badge.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
@import (reference) '../variables.less';

.@{prefix}-badge {
display: inline-block;
margin-left: 6px;
padding: 1px 7px;
color: #fff;
font-size: 13px;
line-height: 20px;
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.1);
box-shadow: 0 6px 16px -2px rgba(0, 0, 0, 0.06);
border-radius: 1px;
vertical-align: top;

&:not([type]),
&[type='info'] {
background: @c-primary;
}

&[type='warning'] {
background: #ffc121;
}

&[type='success'] {
background: #8cd225;
}

&[type='error'] {
background: #ff4646;
}
}
8 changes: 8 additions & 0 deletions packages/preset-dumi/src/themes/default/builtins/Badge.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import React from 'react';
import './Badge.less';

export default ({ children, ...props }) => (
<span className="__dumi-default-badge" {...props}>
{children}
</span>
);
1 change: 1 addition & 0 deletions packages/preset-dumi/src/transformer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ function wrapperHtmlByComponent(jsx: string, meta: TransformResult['config']) {
import { Link } from 'umi';
import React from 'react';
import Alert from '${slash(path.join(__dirname, '../themes/default/builtins/Alert.js'))}';
import Badge from '${slash(path.join(__dirname, '../themes/default/builtins/Badge.js'))}';
import DumiPreviewer from '${slash(
path.join(__dirname, '../themes/default/builtins/Previewer.js'),
)}';
Expand Down

0 comments on commit 880ab27

Please sign in to comment.