-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tag-component): tag component (#955)
## Figma Design Document https://www.figma.com/design/RrcLH0mWpIUy4vwuTlDeKN/Baklava-Design-Guide?node-id=25001-1763&t=xA7DTWjCkA2EqaDc-1 ## Implementation General usage example: ```html <bl-tag>In Progress</bl-tag> ``` ### Usage Examples Selectable variant usage: ```html <bl-tag @bl-tag-click="handleTagClick" selected>Selectable tag</bl-tag> ``` The removable variant can be set like this: ```js const handleTagClick=(event)=>{ tags.filter((tag)=>tag.value!==event.value) } <bl-tag variant="removable" @bl-tag-click="handleTagClick">Removable tag</bl-tag> ``` The icon can be set like this: ```html <bl-tag icon="info">Default</bl-tag> ``` The size and disabled attributes can be set like this: ```html <bl-tag size="large" disabled>In Progress</bl-tag> ``` ## API Reference: #### Slots | Name | Description | Default Content | |-------------|-----------------| --------------- | | `icon` slot | Icon of the tag | - | #### Attributes | Attribute | Description | Default Value | |----------------------|-----------------------------------------------|---------------| | size (`string`) | Size of tag(`small`,`medium`,`large`) | medium | | icon (`bl-icon`) | Name of the icon that will be shown in tag | - | | variant (`string`) | Variants of the tag(`selectable`,`removable`) | selectable | | disabled (`boolean`) | Makes tag disabled | false | | selected (`boolean`) | Makes tag selected | false | | value (`string`) | Sets tags value | - | ### Events | Name | Description | Payload | |----------------|----------------------------|-----------------------------------| | `bl-tag-click` | Fires when tag is clicked | `{value:string,selected:boolean}` | --------- Co-authored-by: AykutSarac <[email protected]> Co-authored-by: Buse Selvi <[email protected]> Co-authored-by: Erbil <[email protected]>
- Loading branch information
1 parent
dff1276
commit a59a00b
Showing
8 changed files
with
634 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,7 @@ module.exports = { | |
"calendar", | ||
"table", | ||
"split-button", | ||
"tag", | ||
"datepicker", | ||
], | ||
], | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
:host { | ||
display: inline-block; | ||
max-width: 100%; | ||
} | ||
|
||
.tag { | ||
--bg-color: var(--bl-color-neutral-full); | ||
--color: var(--bl-color-neutral-darker); | ||
--font: var(--bl-font-title-4-medium); | ||
--padding-vertical: var(--bl-size-2xs); | ||
--padding-horizontal: var(--bl-size-xs); | ||
--margin-icon: var(--bl-size-3xs); | ||
--icon-size: var(--bl-size-m); | ||
--height: var(--bl-size-2xl); | ||
--border-radius: var(--bl-size-m); | ||
--remove-icon-size: var(--bl-size-s); | ||
|
||
display: flex; | ||
gap: var(--margin-icon); | ||
justify-content: center; | ||
align-items: center; | ||
box-sizing: border-box; | ||
overflow: hidden; | ||
width: 100%; | ||
border: 1px solid var(--bl-color-neutral-lighter); | ||
border-radius: var(--border-radius); | ||
padding-block: var(--padding-vertical); | ||
padding-inline: var(--padding-horizontal); | ||
background-color: var(--bg-color); | ||
color: var(--color, white); | ||
font: var(--font); | ||
font-kerning: none; | ||
height: var(--height); | ||
} | ||
|
||
:host([variant="selectable"]) .tag { | ||
cursor: pointer; | ||
user-select: none; | ||
} | ||
|
||
:host([variant="selectable"]) .tag:hover { | ||
background-color: var(--bl-color-neutral-lightest); | ||
} | ||
|
||
:host([variant="selectable"][selected]) .tag { | ||
border-color: var(--bl-color-neutral-darker); | ||
background-color: var(--bl-color-neutral-darker); | ||
|
||
--color: var(--bl-color-neutral-full); | ||
} | ||
|
||
:host([variant="selectable"][disabled]) .tag { | ||
background-color: var(--bl-color-neutral-lightest); | ||
border-color: var(--bl-color-neutral-lightest); | ||
color: var(--bl-color-neutral-light); | ||
cursor: not-allowed; | ||
} | ||
|
||
:host([variant="removable"]) .remove-button { | ||
--bl-border-radius-m: var(--bl-border-radius-circle); | ||
} | ||
|
||
:host([size="small"]) .tag { | ||
--font: var(--bl-font-title-4-medium); | ||
--height: var(--bl-size-xl); | ||
--icon-size: var(--bl-size-s); | ||
--border-radius: var(--bl-size-xs); | ||
--padding-vertical: 0px; | ||
--padding-horizontal: var(--bl-size-2xs); | ||
--remove-icon-size: var(--bl-size-xs); | ||
} | ||
|
||
:host([size="large"]) .tag { | ||
--font: var(--bl-font-title-3-medium); | ||
--padding-vertical: var(--bl-size-2xs); | ||
--padding-horizontal: var(--bl-size-m); | ||
--height: var(--bl-size-3xl); | ||
--icon-size: var(--bl-size-m); | ||
--border-radius: var(--bl-size-l); | ||
} | ||
|
||
:host([variant="removable"][size="small"]) .tag { | ||
--padding-horizontal: var(--bl-size-2xs) 0px; | ||
} | ||
|
||
:host([variant="removable"]) .tag { | ||
--padding-horizontal: var(--bl-size-xs) var(--bl-size-3xs); | ||
} | ||
|
||
:host([variant="removable"][size="large"]) .tag { | ||
--padding-horizontal: var(--bl-size-m) var(--bl-size-2xs); | ||
} | ||
|
||
slot[name="icon"] bl-icon { | ||
font-size: var(--icon-size); | ||
color: var(--color); | ||
} |
Oops, something went wrong.