-
Notifications
You must be signed in to change notification settings - Fork 0
IBX-7844: Tag component #62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
+432
−10
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,226 @@ | ||
@use 'sass:map'; | ||
@use 'functions' as *; | ||
@use 'variables' as *; | ||
@use 'mixins/tags' as mixins; | ||
|
||
$tags-types: ( | ||
'primary': ( | ||
'default': ( | ||
'text': $color-primary-80, | ||
'bg': $color-primary-10, | ||
'border': $color-primary-60, | ||
), | ||
'dark': ( | ||
'text': $color-primary-60, | ||
'bg': transparent, | ||
'border': $color-primary-80, | ||
), | ||
), | ||
'primary-alt': ( | ||
'default': ( | ||
'text': $color-primary_alt-90, | ||
'bg': $color-primary_alt-20, | ||
'border': $color-primary_alt-60, | ||
), | ||
'dark': ( | ||
'text': $color-primary_alt-60, | ||
'bg': transparent, | ||
'border': $color-primary_alt-90, | ||
), | ||
), | ||
'success': ( | ||
'default': ( | ||
'text': $color-success-90, | ||
'bg': $color-success-10, | ||
'border': $color-success-60, | ||
), | ||
'dark': ( | ||
'text': $color-success-70, | ||
'bg': transparent, | ||
'border': $color-success-80, | ||
), | ||
), | ||
'info': ( | ||
'default': ( | ||
'text': $color-info-100, | ||
'bg': $color-info-10, | ||
'border': $color-info-60, | ||
), | ||
'dark': ( | ||
'text': $color-info-70, | ||
'bg': transparent, | ||
'border': $color-info-80, | ||
), | ||
), | ||
'warning': ( | ||
'default': ( | ||
'text': $color-warning-100, | ||
'bg': $color-warning-10, | ||
'border': $color-warning-70, | ||
), | ||
'dark': ( | ||
'text': $color-warning-70, | ||
'bg': transparent, | ||
'border': $color-warning-90, | ||
), | ||
), | ||
'neutral': ( | ||
'default': ( | ||
'text': $color-neutral-190, | ||
'bg': $color-neutral-20, | ||
'border': $color-neutral-170, | ||
), | ||
'dark': ( | ||
'text': $color-neutral-110, | ||
'bg': transparent, | ||
'border': $color-neutral-140, | ||
), | ||
), | ||
'error': ( | ||
'default': ( | ||
'text': $color-error-90, | ||
'bg': $color-error-10, | ||
'border': $color-error-90, | ||
), | ||
'dark': ( | ||
'text': $color-error-70, | ||
'bg': transparent, | ||
'border': $color-error-80, | ||
), | ||
), | ||
'icon-tag': ( | ||
'default': ( | ||
'text': $color-neutral-210, | ||
'bg': $color-neutral-20, | ||
'border': $color-neutral-110, | ||
), | ||
'dark': ( | ||
'text': $color-neutral-90, | ||
'bg': transparent, | ||
'border': $color-neutral-180, | ||
), | ||
), | ||
'success-ghost': ( | ||
'default': ( | ||
'text': $color-neutral-240, | ||
'bg': transparent, | ||
'border': transparent, | ||
'dot': $color-success-90, | ||
), | ||
'dark': ( | ||
'text': $color-neutral-10, | ||
'bg': transparent, | ||
'border': transparent, | ||
'dot': $color-success-70, | ||
), | ||
), | ||
'neutral-ghost': ( | ||
'default': ( | ||
'text': $color-neutral-240, | ||
'bg': transparent, | ||
'border': transparent, | ||
'dot': $color-neutral-120, | ||
), | ||
'dark': ( | ||
'text': $color-neutral-10, | ||
'bg': transparent, | ||
'border': transparent, | ||
'dot': $color-neutral-120, | ||
), | ||
), | ||
'error-ghost': ( | ||
'default': ( | ||
'text': $color-neutral-240, | ||
'bg': transparent, | ||
'border': transparent, | ||
'dot': $color-error-90, | ||
), | ||
'dark': ( | ||
'text': $color-neutral-10, | ||
'bg': transparent, | ||
'border': transparent, | ||
'dot': $color-error-70, | ||
), | ||
), | ||
); | ||
|
||
$tags-sizes: ( | ||
'medium': ( | ||
'text': $text-font-size-s, | ||
'padding-x': calculateRem(8px), | ||
'padding-y': calculateRem(3px), | ||
'dot': calculateRem(6px), | ||
), | ||
'small': ( | ||
'text': $text-font-size-xs, | ||
'padding-x': calculateRem(4px), | ||
'padding-y': 0, | ||
'dot': calculateRem(4px), | ||
), | ||
); | ||
|
||
.ids-tag { | ||
position: relative; | ||
display: inline-flex; | ||
align-items: center; | ||
justify-content: center; | ||
white-space: nowrap; | ||
border: calculateRem(1px) solid var(--ids-default-border-color); | ||
border-radius: calculateRem(16px); | ||
padding: calculateRem(3px) calculateRem(8px); | ||
font-size: $text-font-size-s; | ||
color: var(--ids-default-text-color); | ||
fill: var(--ids-default-text-color); | ||
background: var(--ids-default-bg-color); | ||
transition: all 1s $transition-timing-function; | ||
|
||
@each $name, $theme in $tags-types { | ||
albozek marked this conversation as resolved.
Show resolved
Hide resolved
|
||
&--#{$name} { | ||
@include mixins.tag-variant(map.get($theme, 'default')); | ||
} | ||
|
||
//TODO: decide way of implementing variant on dark background | ||
&--#{$name}.ids-tag--dark { | ||
@include mixins.tag-variant(map.get($theme, 'dark')); | ||
|
||
&.ids-tag::before { | ||
albozek marked this conversation as resolved.
Show resolved
Hide resolved
|
||
content: ''; | ||
position: absolute; | ||
top: calculateRem(-30px); | ||
left: calculateRem(-60px); | ||
right: calculateRem(-60px); | ||
bottom: calculateRem(-30px); | ||
background: $color-neutral-240; | ||
z-index: -1; | ||
} | ||
} | ||
} | ||
|
||
@each $name, $values in $tags-sizes { | ||
&--#{$name} { | ||
font-size: map.get($values, 'text'); | ||
padding: map.get($values, 'padding-y') map.get($values, 'padding-x'); | ||
} | ||
} | ||
|
||
&__content { | ||
line-height: $base-line-height; | ||
} | ||
|
||
&__ghost-dot { | ||
margin: 0 calculateRem(6px) calculateRem(2px) 0; | ||
border-radius: 50%; | ||
background: var(--ids-default-dot-color); | ||
@each $size, $values in $tags-sizes { | ||
.ids-tag--#{$size} & { | ||
width: map.get($values, 'dot'); | ||
height: map.get($values, 'dot'); | ||
} | ||
} | ||
} | ||
|
||
&__icon { | ||
line-height: 0; | ||
margin-right: calculateRem(4px); | ||
} | ||
} |
This file contains hidden or 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 hidden or 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,16 @@ | ||
@use 'sass:map'; | ||
@use '../functions' as *; | ||
|
||
@mixin tag-state($variables, $prefix) { | ||
@each $key, $value in $variables { | ||
--ids-#{$prefix}-#{$key}-color: #{$value}; | ||
} | ||
} | ||
|
||
@mixin tag-variant($default, $dark: false) { | ||
@include tag-state($default, 'default'); | ||
|
||
@if $dark { | ||
@include tag-state($dark, 'dark'); | ||
} | ||
} |
This file contains hidden or 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 hidden or 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,105 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
|
||
import { Tag, TagGhostType, TagSize, TagType } from './'; | ||
|
||
const meta: Meta<typeof Tag> = { | ||
component: Tag, | ||
parameters: { | ||
layout: 'centered', | ||
}, | ||
tags: ['autodocs', 'foundation'], | ||
args: { | ||
children: 'Label', | ||
size: TagSize.Medium, | ||
}, | ||
}; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof Tag>; | ||
albozek marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
export const Primary: Story = { | ||
name: 'Primary / Default', | ||
args: { | ||
type: TagType.Primary, | ||
}, | ||
}; | ||
|
||
export const PrimaryAlt: Story = { | ||
name: 'Primary Alt', | ||
args: { | ||
type: TagType.PrimaryAlt, | ||
}, | ||
}; | ||
|
||
export const PrimaryAltSmall: Story = { | ||
name: 'Primary Alt Small', | ||
args: { | ||
type: TagType.PrimaryAlt, | ||
size: TagSize.Small, | ||
}, | ||
}; | ||
|
||
export const Success: Story = { | ||
name: 'Success', | ||
args: { | ||
type: TagType.Success, | ||
}, | ||
}; | ||
|
||
export const Info: Story = { | ||
name: 'Info', | ||
args: { | ||
type: TagType.Info, | ||
}, | ||
}; | ||
|
||
export const Warning: Story = { | ||
name: 'Warning', | ||
args: { | ||
type: TagType.Warning, | ||
}, | ||
}; | ||
|
||
export const Neutral: Story = { | ||
name: 'Neutral', | ||
args: { | ||
type: TagType.Neutral, | ||
}, | ||
}; | ||
|
||
export const Error: Story = { | ||
name: 'Error', | ||
args: { | ||
type: TagType.Error, | ||
}, | ||
}; | ||
|
||
export const IconTag: Story = { | ||
name: 'Icon tag', | ||
args: { | ||
icon: 'translation-language', | ||
type: TagType.IconTag, | ||
}, | ||
}; | ||
|
||
export const SuccessGhost: Story = { | ||
name: 'Success Ghost', | ||
args: { | ||
type: TagGhostType.SuccessGhost, | ||
}, | ||
}; | ||
|
||
export const NeutralGhost: Story = { | ||
name: 'Neutral Ghost', | ||
args: { | ||
type: TagGhostType.NeutralGhost, | ||
}, | ||
}; | ||
|
||
export const ErrorGhost: Story = { | ||
name: 'Error Ghost', | ||
args: { | ||
type: TagGhostType.ErrorGhost, | ||
}, | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.