Closed CapitalMarkets closed 1 year ago
Can you provide a minimal reproduction to help me troubleshoot?
@Dunqing hope this helps preset-theme-issue.zip
Sorry for taking so long to get back to you. I looked closer and found that the generated file contained text-primary
CSS.
Thanks for the reply and no problem about the time.
I see the point you have made - that there is CSS information for text-primary color:rgba(var(--un-preset-theme-colors-primary) but I didn't understand why this is important.
Forgive me if I misunderstand how CSS works but in my understanding - yes the CSS variable is there hold the value for text primary color but what is the value of the variable?
1) Checkbox.svelte - the themes from the plugin config (autumn, winter, spring, summer) are not shown anywhere in this component to set variable.
2) NewBox.svelte - the plugin has included css classes for the themes in the config that actually set the variable: :root{--un-preset-theme-colors-primary:16, 34, 51;} .autumn{--un-preset-theme-colors-primary:246,119, 47;} .spring{--un-preset-theme-colors-primary:51, 50,240;} .summer{--un-preset-theme-colors-primary:22, 67, 47;} .winter{--un-preset-theme-colors-primary:134, 121, 153;}
Also shouldn't we see / layer: theme / section in both example outputs if everything is ok ?
Yes, The Checkbox.svelte is missing layer: theme
, this is not working. but I don't find the reason for this issue.
I tried adding text-red
in Checkbox.html, but the generated Checkbox.svelte still isn't contain text-red
class, I guess this issue maybe don't work in external files. And I also noticed that your project doesn't seem to do so as required by the unocss documentation. This could also be the reason why it doesn't work
@Dunqing
And I also noticed that your project doesn't seem to do so as required by the unocss documentation
The unocss documentation there is talking about Extractors for SvelteKit but this one is not needed because I am using SVELTE/SVELEKIT SCOPED MODE ("There is no need to add the extractorSvelte when using svelte-scoped mode.")
:warning::warning::warning: I have good news for you :smile::smile::smile:
OK - so I did some debugging today of the plugin:
I start to add console.log() and JSON.stringify() to _nodemodules/unocss-preset-theme/dist/index.cjs
I COULD NOT FIND ANY PROBLEMS!!! :+1:
So I start to think, MAYBE the Checkbox component is broken or has other problem.
:computer: I created EXTRA-BOX (copy of NEW-BOX) - I can see theme layer and theme colours.
:computer: I split EXTRA-BOX into External files - I CAN SEE theme layer and theme colours :eyes: :eyes:
:computer: I refactor CHECK-BOX to remove External files - I still CANNOT SEE any theme layer or colours :eyes: :eyes:
SO THE PROBLEM IS NOT EXTERNAL FILES BUT THE NAME OF THE COMPONENT??? :thinking:
To confirm, I create:
Result:
Above problem is NOT related to this plugin.
Minimal reproduction with above result: preset-theme-issue-working.zip
I'm primarily a back-end developer only now starting out on my frontend journey so it's possible I've inadvertently made a mistake somewhere.
I have two Svelte components I am using to learn what is going on with npm, typescript, css, Svelte, Unocss, pre-processors, presets, variants, etc:
Checkbox.svelte which uses the external files approach provided by svelte-preprocess:
Newbox.svelte which doesn't use external files but instead places each of the template, styling and logic in the same Svelte file.
THE PROBLEM
After npm run build has finished:
The only real difference between these components are their names and this External vs. non-External files usage.
GENERATED FILES (dist folder)
Checkbox.svelte
Newbox.svelte
CONFIG THAT MAY HELP
unocss is running in svelte-scoped mode so no global css files being generated
Package.json
Svelte.config.js
Unocss.config.ts