I’ve made a theme (css only) with a variable width.
Now I think about to share it, but not every one wants the variable width. So my consideration was to use variables to set the width inside the theme settings.
I know I need a settings.yamlwith e.g. this code:
composer width:
default: 1110
type: integer
description: "Set the width of the composer"
header width:
default: 1110
type: integer
description: "Set the width of the header"
Now I’m not a specialist with CSS so I don’t know how to use these variables inside of SCSS.
Do I need a function for these settings?
Can someone give me an example on how to set the value for the header for example?
So, one more question.
As width you can set px or %, so my variables need to be a string as data type?
But how can I prevent such inputs like 1100 apples?
Ciò che mi infastidisce ora è l’uso di # invece di $ come in altri componenti che ho esaminato.
Quindi cosa devo usare? O non fa differenza?
Ho un’altra domanda sul CSS, ma prima voglio risolvere la domanda di cui sopra.
Naturalmente potrei provarlo, ma voglio essere sicuro di quale sia la cosa corretta.
La mia ipotesi è che sia richiesta in alcuni degli esempi che hai condiviso perché tutte le impostazioni del tema sono variabili di tipo ‘stringa’. L’interpolazione consente di utilizzare tali stringhe in punti che normalmente richiederebbero un tipo di variabile specifico. In molti casi, tuttavia, probabilmente puoi cavartela con un semplice $variabile
Ok, capisco.
Quindi se costringessi gli utenti a usare il colore di sfondo come RGB invece di Hex, e scrivessi il # codificato nel file CSS, potrei usare $.