-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Implementing Rating component (#139)
* feat: Implementing Rating component Co-authored-by: Simeon Simeonoff <[email protected]> Co-authored-by: MPopov <[email protected]> Co-authored-by: Stamen Stoychev <[email protected]> Co-authored-by: Diyan Dimitrov <[email protected]> Co-authored-by: Diyan Dimitrov <[email protected]>
- Loading branch information
1 parent
9c396a2
commit af4c67e
Showing
15 changed files
with
1,184 additions
and
7 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
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
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,23 @@ | ||
import { LitElement } from 'lit'; | ||
|
||
/** | ||
* | ||
* Used when a custom icon/symbol/element needs to be passed to the igc-rating component. | ||
* | ||
* @element igc-rating-symbol | ||
* | ||
* @slot - Default slot for projected symbols/icons. | ||
*/ | ||
export default class IgcRatingSymbolComponent extends LitElement { | ||
public static readonly tagName = 'igc-rating-symbol'; | ||
|
||
protected override createRenderRoot() { | ||
return this; | ||
} | ||
} | ||
|
||
declare global { | ||
interface HTMLElementTagNameMap { | ||
'igc-rating-symbol': IgcRatingSymbolComponent; | ||
} | ||
} |
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,177 @@ | ||
@use '../../styles/common/component'; | ||
@use '../../styles/utilities' as *; | ||
|
||
$size-small: rem(16px); | ||
$size-medium: rem(20px); | ||
$size-large: rem(24px); | ||
$spacing: rem(2px); | ||
$color-label: color(gray, 700) !default; | ||
$color-symbols: color(gray, 900) !default; | ||
$selected-color: color(primary) !default; | ||
$disabled-color: color(gray, 400) !default; | ||
$disabled-selected-color: color(gray, 600) !default; | ||
|
||
:host { | ||
display: inline-flex; | ||
font-family: var(--igc-font-family); | ||
align-items: flex-start; | ||
flex-direction: column; | ||
gap: $spacing * 2; | ||
} | ||
|
||
%fraction { | ||
position: absolute; | ||
overflow: hidden; | ||
inset-inline-start: 0; | ||
min-width: 0 !important; | ||
z-index: 1; | ||
} | ||
|
||
slot { | ||
display: none; | ||
} | ||
|
||
[part='base'] { | ||
position: relative; | ||
display: inline-flex; | ||
user-select: none; | ||
} | ||
|
||
[part~='label'] { | ||
@include type-category('caption'); | ||
|
||
color: $color-label; | ||
padding-inline-start: $spacing; | ||
} | ||
|
||
[part~='symbols-wrapper'] { | ||
color: $color-symbols; | ||
position: relative; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
padding: $spacing; | ||
gap: $spacing; | ||
counter-reset: symbols; | ||
inset-inline-start: 0; | ||
} | ||
|
||
[part~='fraction'] { | ||
@extend %fraction; | ||
|
||
[part='symbols-wrapper'] { | ||
@extend %fraction; | ||
|
||
color: $selected-color; | ||
|
||
[part~='symbol'] { | ||
filter: grayscale(0); | ||
} | ||
} | ||
} | ||
|
||
[part~='symbol'] { | ||
color: inherit; | ||
font-size: 100%; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
filter: grayscale(100%); | ||
cursor: pointer; | ||
|
||
igc-icon { | ||
color: inherit; | ||
} | ||
|
||
&:empty { | ||
&::before { | ||
content: counter(symbols); | ||
counter-increment: symbols; | ||
} | ||
} | ||
} | ||
|
||
:host([disabled]) { | ||
pointer-events: none; | ||
|
||
[part~='label'] { | ||
color: $disabled-color !important; | ||
} | ||
|
||
[part~='symbols-wrapper'] { | ||
color: $disabled-color; | ||
} | ||
|
||
[part~='fraction'] { | ||
[part='symbols-wrapper'] { | ||
color: $disabled-selected-color; | ||
filter: grayscale(50%); | ||
} | ||
} | ||
} | ||
|
||
[part~='large'] { | ||
min-width: $size-large; | ||
min-height: $size-large; | ||
line-height: $size-large; | ||
width: $size-large; | ||
height: $size-large; | ||
|
||
igc-icon { | ||
width: $size-large; | ||
height: $size-large; | ||
font-size: $size-large; | ||
} | ||
} | ||
|
||
[part~='medium'] { | ||
min-width: $size-medium; | ||
min-height: $size-medium; | ||
line-height: $size-medium; | ||
width: $size-medium; | ||
height: $size-medium; | ||
|
||
igc-icon { | ||
width: $size-medium; | ||
height: $size-medium; | ||
font-size: $size-medium; | ||
} | ||
} | ||
|
||
[part~='small'] { | ||
min-width: $size-small; | ||
min-height: $size-small; | ||
line-height: $size-small; | ||
width: $size-small; | ||
height: $size-small; | ||
|
||
igc-icon { | ||
width: $size-small; | ||
height: $size-small; | ||
font-size: $size-small; | ||
} | ||
} | ||
|
||
[part='label large'], | ||
[part='label medium'], | ||
[part='label small'] { | ||
height: auto; | ||
width: auto; | ||
min-height: 0; | ||
min-width: 0; | ||
} | ||
|
||
[part='fraction large'] { | ||
min-height: calc(#{$size-large} + (#{$spacing} * 2)); | ||
height: calc(#{$size-large} + (#{$spacing} * 2)); | ||
} | ||
|
||
[part='fraction medium'] { | ||
min-height: calc(#{$size-medium} + (#{$spacing} * 2)); | ||
height: calc(#{$size-medium} + (#{$spacing} * 2)); | ||
} | ||
|
||
[part='fraction small'] { | ||
min-height: calc(#{$size-small} + (#{$spacing} * 2)); | ||
height: calc(#{$size-small} + (#{$spacing} * 2)); | ||
} |
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,10 @@ | ||
@use '../../styles/utilities' as *; | ||
|
||
$spacing: rem(4px); | ||
|
||
[part~='label'] { | ||
@include type-category('body-1'); | ||
|
||
color: color(gray, 900); | ||
padding-inline-start: $spacing; | ||
} |
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,29 @@ | ||
@use '../../styles/utilities' as *; | ||
|
||
$spacing: rem(6px); | ||
$disabled-color: color(gray, 200) !default; | ||
$disabled-selected-color: color(gray, 500) !default; | ||
$disabled-label-color: color(gray, 400) !default; | ||
|
||
[part~='label'] { | ||
@include type-category('subtitle-2'); | ||
|
||
color: color(gray, 900); | ||
padding-inline-start: $spacing; | ||
} | ||
|
||
:host([disabled]) { | ||
[part~='symbols-wrapper'] { | ||
color: $disabled-color; | ||
} | ||
|
||
[part~='label'] { | ||
color: $disabled-label-color; | ||
} | ||
|
||
[part~='fraction'] { | ||
[part~='symbols-wrapper'] { | ||
color: $disabled-selected-color; | ||
} | ||
} | ||
} |
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,10 @@ | ||
@use '../../styles/utilities' as *; | ||
|
||
$spacing: rem(5px); | ||
|
||
[part~='label'] { | ||
@include type-category('body-1'); | ||
|
||
color: color(gray, 900); | ||
padding-inline-start: $spacing; | ||
} |
Oops, something went wrong.