How do I change `customize` dynamically, and why doesn't the component update with ticks?
Open
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 1.2k
- Forks
- 96
- Avg merge
- 8h 12m
- Merged PRs (30d)
- 2
Description
How do I change the fill and stroke during the lifecycle?
agreeonly works when not touching thedisplayproperty and usingsvgmode.agree2doesn't work, with or withoutsvgmode.
<script setup lang="ts">
const agree = ref(false)
const agree2 = ref(false)
const setChecked = (content: string) =>
content
.replaceAll(/stroke="[^"]*"/g, 'stroke="black"')
.replaceAll(/fill="[^"]*"/g, 'fill="white"')
const setUnchecked = (content: string) =>
content
.replaceAll(/stroke="[^"]*"/g, 'stroke="black"')
.replaceAll(/fill="[^"]*"/g, 'fill="yellow"')
const customize = (a, b) => (content: string) =>
content.replaceAll(/stroke="[^"]*"/g, `stroke="${a}"`).replaceAll(/fill="[^"]*"/g, `fill="${b}"`)
</script>
<template>
<label>
<input
v-model="agree"
required
type="checkbox"
class="invisible absolute -z-10"
>
<Icon
mode="svg"
:customize="setChecked"
name="local:checkbox"
:class="{ hidden: !agree }"
/>
<Icon
:class="{ hidden: agree }"
mode="svg"
:customize="setUnchecked"
name="local:checkbox"
/>
Yes
</label>
<label>
<input
v-model="agree2"
required
type="checkbox"
class="invisible absolute -z-10"
>
<Icon
mode="svg"
:customize="customize('black', 'white')"
name="local:checkbox"
:class="{ hidden: !agree }"
/>
<Icon
:class="{ hidden: agree }"
mode="svg"
:customize="customize('black', 'yellow')"
name="local:checkbox"
/>
Yes
</label>
</template>
SVG
<svg width="20" height="20" viewBox="0 0 20 20" fill="none">
<rect x="0.5" y="0.5" width="19" height="19" rx="3.5" fill="#24A3B6"/>
<rect x="0.5" y="0.5" width="19" height="19" rx="3.5" stroke="#24A3B6"/>
<g clip-path="url(#clip0_4188_74097)">
<path d="M6 9.5L9.125 12.625L15.375 6.375" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
</g>
<defs>
<clipPath id="clip0_4188_74097">
<rect width="15" height="15" fill="white" transform="translate(3 2)"/>
</clipPath>
</defs>
</svg>
`app.config.ts`
// app.config.ts
export default defineAppConfig({
icon: {
size : '20px',
customCollections: [
{
prefix: 'local',
dir : './assets/images/icons/'
}
],
})
The number of times I've restarted Nuxt for debugging this is horrendous.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the two checkbox examples using the component and the local collection configured in app.config.ts, comparing svg and non-svg modes. Trace how customize, display, and reactive updates are handled, then verify that fill and stroke changes are reflected during the component lifecycle for both examples.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- nuxt, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100