refactor: icons

This commit is contained in:
Lucas Larroche 2023-03-28 20:34:28 +07:00
parent 7fa3c4a099
commit 0b081e3657
15 changed files with 104 additions and 152 deletions

View file

@ -79,20 +79,6 @@
// Marker
&::after {
height: calc(1rem * var(#{$}line-height, 1.5));
background-image: var(#{$}icon-chevron-button);
}
@if $enable-classes {
&.outline {
&::after {
background-image: var(#{$}icon-chevron);
}
}
&.contrast:not(.outline) {
&::after {
background-image: var(#{$}icon-chevron-button-contrast);
}
}
}
}
}

View file

@ -33,28 +33,6 @@
content: "";
}
}
// Marker as button
summary[role="button"],
> button {
&::after {
background-image: var(#{$}icon-chevron-button);
}
@if $enable-classes {
&.outline {
&::after {
background-image: var(#{$}icon-chevron);
}
}
&.contrast:not(.outline) {
&::after {
background-image: var(#{$}icon-chevron-button-contrast);
}
}
}
}
}
// Container type accordion

View file

@ -29,27 +29,6 @@
&:empty {
text-align: center;
}
// Primary and secondary buttons
&:is(button, [type="submit"], [type="button"], [type="reset"], [role="button"]) {
&::before {
background-image: var(#{$}icon-loading-button);
}
@if $enable-classes {
&.outline {
&::before {
background-image: var(#{$}icon-loading);
}
}
&.contrast:not(.outline) {
&::before {
background-image: var(#{$}icon-loading-button-contrast);
}
}
}
}
}
// Buttons and links

View file

@ -199,11 +199,19 @@
}
// Chevron icons
@if map.get($modules, "forms/basics") or
map.get($modules, "components/accordion") or
map.get($modules, "components/dropdown")
{
#{$✨}icon-chevron-button-contrast: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='#{functions.display-rgb($black)}' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
@if map.get($modules, "components/accordion") or map.get($modules, "components/dropdown") {
// Change the icon color to black for accordion and dropdown .contrast buttons
@if $enable-classes {
details {
summary {
&[role="button"].contrast:not(.outline) {
&::after {
filter: brightness(0);
}
}
}
}
}
}
// Form validation icons
@ -214,7 +222,22 @@
// Loading icon (animated)
@if map.get($modules, "components/loading") {
#{$✨}icon-loading-button-contrast: url("data:image/svg+xml,%3Csvg fill='none' height='24' width='24' viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg' %3E%3Cstyle%3E g %7B animation: rotate 2s linear infinite; transform-origin: center center; %7D circle %7B stroke-dasharray: 75,100; stroke-dashoffset: -5; animation: dash 1.5s ease-in-out infinite; stroke-linecap: round; %7D @keyframes rotate %7B 0%25 %7B transform: rotate(0deg); %7D 100%25 %7B transform: rotate(360deg); %7D %7D @keyframes dash %7B 0%25 %7B stroke-dasharray: 1,100; stroke-dashoffset: 0; %7D 50%25 %7B stroke-dasharray: 44.5,100; stroke-dashoffset: -17.5; %7D 100%25 %7B stroke-dasharray: 44.5,100; stroke-dashoffset: -62; %7D %7D %3C/style%3E%3Cg%3E%3Ccircle cx='12' cy='12' r='10' fill='none' stroke='#{functions.display-rgb($black)}' stroke-width='4' /%3E%3C/g%3E%3C/svg%3E");
// Change the icon color to black for .contrast buttons
@if $enable-classes {
[aria-busy="true"]:not(input, select, textarea) {
&.contrast:is(
button,
[type="submit"],
[type="button"],
[type="reset"],
[role="button"]
):not(.outline) {
&::before {
filter: brightness(0);
}
}
}
}
}
// Document

View file

@ -198,25 +198,12 @@
#{$✨}tooltip-color: var(#{$}contrast-inverse);
}
// Chevron icons
@if map.get($modules, "forms/basics") or
map.get($modules, "components/accordion") or
map.get($modules, "components/dropdown")
{
#{$✨}icon-chevron-button-contrast: var(#{$}icon-chevron-button);
}
// Form validation icons
@if map.get($modules, "forms/basics") {
#{$✨}icon-valid: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='#{functions.display-rgb(mix($jade-450, $zinc-750))}' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'%3E%3C/polyline%3E%3C/svg%3E");
#{$✨}icon-invalid: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='#{functions.display-rgb(mix($red-500, $zinc-750))}' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'%3E%3C/circle%3E%3Cline x1='12' y1='8' x2='12' y2='12'%3E%3C/line%3E%3Cline x1='12' y1='16' x2='12.01' y2='16'%3E%3C/line%3E%3C/svg%3E");
}
// Loading icon (animated)
@if map.get($modules, "components/loading") {
#{$✨}icon-loading-button-contrast: var(#{$}icon-loading-button);
}
// Document
color-scheme: light;
}

View file

@ -97,7 +97,24 @@
map.get($modules, "components/dropdown")
{
#{$✨}icon-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='#{functions.display-rgb($zinc-400)}' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
#{$✨}icon-chevron-button: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='#{functions.display-rgb($white)}' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}
// Chevron icons
// Change the icon color to white for accordion and dropdown buttons
@if map.get($modules, "components/accordion") or map.get($modules, "components/dropdown") {
details {
summary {
$selector: '&[role="button"]';
@if $enable-classes {
$selector: "#{$selector}:not(.outline)";
}
#{$selector} {
&::after {
filter: brightness(0) invert(1);
}
}
}
}
}
// Datetime icons
@ -120,7 +137,19 @@
@if map.get($modules, "components/loading") {
// Inspired by https://codepen.io/aleksander351/pen/KzgKPo
#{$✨}icon-loading: url("data:image/svg+xml,%3Csvg fill='none' height='24' width='24' viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg' %3E%3Cstyle%3E g %7B animation: rotate 2s linear infinite; transform-origin: center center; %7D circle %7B stroke-dasharray: 75,100; stroke-dashoffset: -5; animation: dash 1.5s ease-in-out infinite; stroke-linecap: round; %7D @keyframes rotate %7B 0%25 %7B transform: rotate(0deg); %7D 100%25 %7B transform: rotate(360deg); %7D %7D @keyframes dash %7B 0%25 %7B stroke-dasharray: 1,100; stroke-dashoffset: 0; %7D 50%25 %7B stroke-dasharray: 44.5,100; stroke-dashoffset: -17.5; %7D 100%25 %7B stroke-dasharray: 44.5,100; stroke-dashoffset: -62; %7D %7D %3C/style%3E%3Cg%3E%3Ccircle cx='12' cy='12' r='10' fill='none' stroke='#{functions.display-rgb($zinc-400)}' stroke-width='4' /%3E%3C/g%3E%3C/svg%3E");
#{$✨}icon-loading-button: url("data:image/svg+xml,%3Csvg fill='none' height='24' width='24' viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg' %3E%3Cstyle%3E g %7B animation: rotate 2s linear infinite; transform-origin: center center; %7D circle %7B stroke-dasharray: 75,100; stroke-dashoffset: -5; animation: dash 1.5s ease-in-out infinite; stroke-linecap: round; %7D @keyframes rotate %7B 0%25 %7B transform: rotate(0deg); %7D 100%25 %7B transform: rotate(360deg); %7D %7D @keyframes dash %7B 0%25 %7B stroke-dasharray: 1,100; stroke-dashoffset: 0; %7D 50%25 %7B stroke-dasharray: 44.5,100; stroke-dashoffset: -17.5; %7D 100%25 %7B stroke-dasharray: 44.5,100; stroke-dashoffset: -62; %7D %7D %3C/style%3E%3Cg%3E%3Ccircle cx='12' cy='12' r='10' fill='none' stroke='#{functions.display-rgb($white)}' stroke-width='4' /%3E%3C/g%3E%3C/svg%3E");
// Change the icon color to white for buttons
[aria-busy="true"]:not(input, select, textarea) {
$selector: '&:is(button, [type="submit"], [type="button"], [type="reset"], [role="button"])';
@if $enable-classes {
$selector: "#{$selector}:not(.outline)";
}
#{$selector} {
&::before {
filter: brightness(0) invert(1);
}
}
}
}
}