Files
webawesome/src/components/progress-ring/progress-ring.styles.ts

67 lines
1.5 KiB
TypeScript
Raw Normal View History

2021-07-09 20:45:44 -04:00
import { css } from 'lit';
2022-03-24 08:01:09 -04:00
import componentStyles from '../../styles/component.styles';
2021-07-09 20:45:44 -04:00
export default css`
${componentStyles}
:host {
2021-09-17 18:15:13 -04:00
--size: 128px;
--track-width: 4px;
--track-color: var(--sl-color-neutral-200);
--indicator-color: var(--sl-color-primary-600);
2021-07-09 20:45:44 -04:00
display: inline-flex;
}
.progress-ring {
display: inline-flex;
align-items: center;
justify-content: center;
position: relative;
}
.progress-ring__image {
2021-09-17 18:15:13 -04:00
width: var(--size);
height: var(--size);
2021-07-09 20:45:44 -04:00
transform: rotate(-90deg);
transform-origin: 50% 50%;
}
2021-09-17 18:15:13 -04:00
.progress-ring__track,
.progress-ring__indicator {
2022-01-24 08:32:05 -05:00
--radius: calc(var(--size) / 2 - var(--track-width) * 0.5);
2021-09-20 23:14:39 -04:00
--circumference: calc(var(--radius) * 2 * 3.141592654);
2021-09-17 18:15:13 -04:00
fill: none;
stroke-width: var(--track-width);
r: var(--radius);
cx: calc(var(--size) / 2);
cy: calc(var(--size) / 2);
}
2021-07-09 20:45:44 -04:00
.progress-ring__track {
stroke: var(--track-color);
}
.progress-ring__indicator {
stroke: var(--indicator-color);
2021-09-17 18:15:13 -04:00
stroke-linecap: round;
2021-09-20 22:33:17 -04:00
transition: 0.35s stroke-dashoffset;
2021-09-17 18:15:13 -04:00
stroke-dasharray: var(--circumference) var(--circumference);
2021-09-20 23:14:39 -04:00
stroke-dashoffset: calc(var(--circumference) - var(--percentage) * var(--circumference));
2021-07-09 20:45:44 -04:00
}
.progress-ring__label {
display: flex;
align-items: center;
justify-content: center;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
text-align: center;
user-select: none;
}
`;