Skip to content

Commit

Permalink
feat(icon): separate color with stroke color
Browse files Browse the repository at this point in the history
  • Loading branch information
CyanSalt committed Apr 3, 2024
1 parent 8ba2126 commit 7bbe9c3
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
22 changes: 20 additions & 2 deletions docs/components/icon.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,25 @@ View all available icons [here](https://lucide.dev/icons/).

</RStyle>

<RStyle name="line-width">
<RStyle name="stroke-color">

<template #values>

`<color>`

</template>

<template #default-value>

`var(--r-icon-color)`

</template>

Stroke line color of the icon.

</RStyle>

<RStyle name="stroke-width">

<template #values>

Expand All @@ -198,7 +216,7 @@ View all available icons [here](https://lucide.dev/icons/).

</template>

Line width of the icon.
Stroke line width of the icon.

</RStyle>

Expand Down
7 changes: 4 additions & 3 deletions src/icon/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ const getReactionState = useReactionState()
function draw(rc: RoughSVG, svg: SVGSVGElement) {
emit('will-draw')
getReactionState(reactions)
const strokeWidth = getLengthProperty(svg, '--r-icon-line-width') ?? 0
const strokeWidth = getLengthProperty(svg, '--r-icon-stroke-width') ?? 0
const options: Options = {
roughness: 0.5,
disableMultiStroke: true,
stroke: 'var(--r-icon-color)',
stroke: 'var(--r-icon-stroke-color)',
strokeWidth,
fill: filled ? 'var(--r-icon-color)' : undefined,
}
Expand Down Expand Up @@ -142,7 +142,8 @@ function draw(rc: RoughSVG, svg: SVGSVGElement) {
<style lang="scss">
.r-icon {
--r-icon-color: var(--r-text-color);
--r-icon-line-width: 2px;
--r-icon-stroke-color: var(--r-icon-color);
--r-icon-stroke-width: 2px;
display: inline-block;
block-size: calc(1em + 4px);
inline-size: calc(1em + 4px);
Expand Down
2 changes: 1 addition & 1 deletion src/select/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ provide(labelsInjection, labels)
}
}
.r-select__icon {
--r-icon-line-width: var(--r-select-border-width);
--r-icon-stroke-width: var(--r-select-border-width);
--r-element-font-size: calc(1em + 4px);
flex: none;
margin-inline-start: calc(var(--r-common-box-padding-inline) - (1em + 4px) / 2 - 4px);
Expand Down

0 comments on commit 7bbe9c3

Please sign in to comment.