Skip to content

Commit

Permalink
🚀 [tag] support size
Browse files Browse the repository at this point in the history
ref #58
  • Loading branch information
higuaifan committed Nov 6, 2024
1 parent a4ae1f8 commit 034b682
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/components/base/tag/MTag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import './tag.css';

export default defineComponent((props: TagProps, { slots }) => {
return () => {
return <div class={['m-tag', `m-tag-${props.type}`]}>
return <div class={['m-tag', `m-tag-${props.type}`, `m-tag-${props.size}`]}>
<div class="m-tag-left"/>
<div class="m-tag-main">
{slots.default?.() ?? ''}
Expand Down
1 change: 1 addition & 0 deletions lib/components/base/tag/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ import { TagProps } from './index';

export const props: MCOPO<TagProps> = {
type: { type: String as MPropType<'default' | 'primary' | 'error' | 'confirm' | 'warning'>, default: 'default' },
size: { type: String as MPropType<'small' | 'default' | 'large'>, default: 'default' },
};
7 changes: 7 additions & 0 deletions lib/components/base/tag/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,11 @@ export declare type TagProps = {
* @enum default|primary|error|confirm|warning
*/
type?: 'default' | 'primary' | 'error' | 'confirm' | 'warning'
/**
* @description button size 按钮大小
* @type string
* @default default
* @enum small|default|large
*/
size?: 'small' | 'default' | 'large'
};
15 changes: 14 additions & 1 deletion lib/components/base/tag/tag.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
:root {
--m-tag-h: 45px;

--m-tag-large: 64px;
--m-tag-default: 45px;
--m-tag-small: 32px;

--m-tag-h: var(--m-tag-default);
--m-tag-w-min: 80px;
--m-tag-border-w: calc(var(--m-tag-h) / 4.5);
}
Expand All @@ -10,6 +15,14 @@
min-width: var(--m-tag-w-min);
height: 100%;
--m-tag-bg: var(--m-color-text-dark);

&.m-tag-large {
--m-tag-h: var(--m-tag-large);
}

&.m-tag-small {
--m-tag-h: var(--m-tag-small);
}
}

.m-tag-left, .m-tag-right {
Expand Down
2 changes: 2 additions & 0 deletions playground/src/lib/Base.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
<m-tag>你好你好你好你好你好</m-tag>

<m-tag type="primary">primary</m-tag>
<m-tag type="primary" size="small">small</m-tag>
<m-tag type="primary" size="large">large</m-tag>
<m-tag type="error">error</m-tag>
<m-tag type="confirm">confirm</m-tag>
<m-tag type="warning">warning</m-tag>
Expand Down

0 comments on commit 034b682

Please sign in to comment.