inherit
217348
0
Jul 27, 2022 7:26:44 GMT -8
Lynx
5,849
January 2015
msg
|
Post by Lynx on Sept 2, 2020 20:52:26 GMT -8
Kami and/or elli (or anyone else who knows): In the stylesheet, I've noticed that there are @ variables (?) there, like @body_background_color: #999999;. I've got some questions, if you don't mind. 1. Can we create our own unique variables there (not sure exactly what they're called, so defaulting to the term variable), such as: @mysetting: #cccccc;? 2. If we can create them, how can they be used (have you made your own and found a use for them)? 3. Any idea if plugins can grab the info off of those? Thanks for any insight!
|
|
Kami
Forum Cat
Posts: 40,201
Mini-Profile Theme: Kami's Mini-Profile
#f35f71
156500
0
Offline
Jul 24, 2021 11:48:29 GMT -8
Kami
40,201
July 2010
kamiyakaoru
Kami's Mini-Profile
|
Post by Kami on Sept 2, 2020 21:03:48 GMT -8
no idea about plugins, but yeah you can create your own.
all you have to do is declare it at the top of your style sheet, eg:
@white: #fff; @light_gray: #f3f3f3; @med_gray_1: #e7e7e7; @med_gray_2: #b6b6b6; @dark_gray: #444;
And then later in your stylesheet simply reference the @ names.
They're most useful for recurring colours / styles. For instance on TARP I reuse the same colour blue for the titlebars, the header, post header/footer, so instead of trying to figure out what exact hex is witch i simply plug in @dark_blue and it fills in the value accordingly.
|
|
inherit
252032
0
Apr 26, 2024 23:51:41 GMT -8
Retread
Tribbial Pursuit.
5,017
January 2018
retread
|
Post by Retread on Sept 3, 2020 8:09:33 GMT -8
1. Can we create our own unique variables there (not sure exactly what they're called, so defaulting to the term variable), such as: @mysetting: #cccccc;? Hi Lynx I think they're called LESS variables. lesscss.org/# The part that begins with @ and is punctuated with : is the variable and the part that follows and is punctuated with ; is obviously the value. You absolutely can create your own. Just be careful to use a unique name that hasn't already been used in the Style Sheet. I don't know if there would be a problem if the variable was defined later in the Style Sheet than where it is used to substitute a value, so to be safe I'd suggest: declare first, substitute later. 2. If we can create them, how can they be used (have you made your own and found a use for them)? As Kami mentioned, they're convenient in any situation where changing a value in one place will automatically change it for many declarations. My favorite use for them is for additions to the Visual Editor. 3. Any idea if plugins can grab the info off of those? I can't say for certain, but I very much doubt it. When a theme is saved, LESS compiles what we see in the 'Style Sheet' and creates the actual publicly available css file which is used with the theme. For instance, if you View Page Source when viewing the Support Forum using the proboards.com theme, you'll see the HTML is referring to this css file: <link rel="stylesheet" type="text/css" media="screen" href="//storage.proboards.com/1/css/kgJlmzgGZtKKY0GoNBfD.css" id="forum_style" /> That file has all the substitutions made for the variables and the variable declarations are not present. I don't think a plugin would be able to access the LESS source file that we see in the Style Sheet via the Admin panel. But we could ask Brian , as I reckon he would know.
|
|
Kami
Forum Cat
Posts: 40,201
Mini-Profile Theme: Kami's Mini-Profile
#f35f71
156500
0
Offline
Jul 24, 2021 11:48:29 GMT -8
Kami
40,201
July 2010
kamiyakaoru
Kami's Mini-Profile
|
Post by Kami on Sept 3, 2020 8:53:14 GMT -8
Hey Retread! Thanks for adding the info about these being LESS variables, I appreciate that.
Not super sure why you had to repeat the information I already provided on how to use them though? Generally, we aren't supposed to repeat information. You tagged me, so it seems you wanted me to notice, and I am rather confused about it.
|
|
inherit
252032
0
Apr 26, 2024 23:51:41 GMT -8
Retread
Tribbial Pursuit.
5,017
January 2018
retread
|
Post by Retread on Sept 3, 2020 9:33:45 GMT -8
Not super sure why you had to repeat the information I already provided on how to use them though? Generally, we aren't supposed to repeat information. You tagged me, so it seems you wanted me to notice, and I am rather confused about it. I tagged you to acknowledge that the beginning of that portion of my reply was already mentioned by you. However, I continued by pointing out new variables aren't limited to the Style Sheet tab of the Advanced Styles & CSS. They can be used when creating new sections of the Visual Editor. If you feel the notification created when I tagged you was a nuisance, I can just refer to your name in plain text in the future. Let me know.
|
|
inherit
97216
0
Nov 26, 2024 13:53:14 GMT -8
Bennett 🚀
Formerly iPokemon.
3,622
January 2007
catattack
iPokemon's Mini-Profile
|
Post by Bennett 🚀 on Sept 3, 2020 9:46:00 GMT -8
1. Can we create our own unique variables there (not sure exactly what they're called, so defaulting to the term variable), such as: @mysetting: #cccccc;? Hi Lynx I think they're called LESS variables. lesscss.org/# The part that begins with @ and is punctuated with : is the variable and the part that follows and is punctuated with ; is obviously the value. You absolutely can create your own. Just be careful to use a unique name that hasn't already been used in the Style Sheet. I don't know if there would be a problem if the variable was defined later in the Style Sheet than where it is used to substitute a value, so to be safe I'd suggest: declare first, substitute later. 2. If we can create them, how can they be used (have you made your own and found a use for them)? As Kami mentioned, they're convenient in any situation where changing a value in one place will automatically change it for many declarations. My favorite use for them is for additions to the Visual Editor. 3. Any idea if plugins can grab the info off of those? I can't say for certain, but I very much doubt it. When a theme is saved, LESS compiles what we see in the 'Style Sheet' and creates the actual publicly available css file which is used with the theme. For instance, if you View Page Source when viewing the Support Forum using the proboards.com theme, you'll see the HTML is referring to this css file: <link rel="stylesheet" type="text/css" media="screen" href="//storage.proboards.com/1/css/kgJlmzgGZtKKY0GoNBfD.css" id="forum_style" /> That file has all the substitutions made for the variables and the variable declarations are not present. I don't think a plugin would be able to access the LESS source file that we see in the Style Sheet via the Admin panel. But we could ask Brian , as I reckon he would know. You could inject your LESS variables into CSS variables, and then you could use those variables in plugins as well. In the theme: :root { --primary: @primary; } In a plugin's CSS: .button-in-plugin { background-color: var(--primary); }
|
|
Kami
Forum Cat
Posts: 40,201
Mini-Profile Theme: Kami's Mini-Profile
#f35f71
156500
0
Offline
Jul 24, 2021 11:48:29 GMT -8
Kami
40,201
July 2010
kamiyakaoru
Kami's Mini-Profile
|
Post by Kami on Sept 3, 2020 9:51:26 GMT -8
Not super sure why you had to repeat the information I already provided on how to use them though? Generally, we aren't supposed to repeat information. You tagged me, so it seems you wanted me to notice, and I am rather confused about it. I tagged you to acknowledge that the beginning of that portion of my reply was already mentioned by you. However, I continued by pointing out new variables aren't limited to the Style Sheet tab of the Advanced Styles & CSS. They can be used when creating new sections of the Visual Editor. If you feel the notification created when I tagged you was a nuisance, I can just refer to your name in plain text in the future. Let me know. I didn't say that, I said I was confused. I appreciate that you took the time to explain your rationale.
|
|
inherit
217348
0
Jul 27, 2022 7:26:44 GMT -8
Lynx
5,849
January 2015
msg
|
Post by Lynx on Sept 3, 2020 10:28:15 GMT -8
|
|
#eb7100
33409
0
1
Nov 24, 2024 4:27:37 GMT -8
Brian
48,130
November 2004
smashmaster3
|
Post by Brian on Sept 3, 2020 14:07:36 GMT -8
I don't think a plugin would be able to access the LESS source file that we see in the Style Sheet via the Admin panel. But we could ask Brian, as I reckon he would know. A workaround was already suggested (though according to MDN it isn't compatible with IE), but I did want to explicitly state that this is the case and any CSS you add to a plugin can't use existing LESS variables nor does it ever go through the LESS compiler.
|
|
inherit
97216
0
Nov 26, 2024 13:53:14 GMT -8
Bennett 🚀
Formerly iPokemon.
3,622
January 2007
catattack
iPokemon's Mini-Profile
|
Post by Bennett 🚀 on Sept 4, 2020 4:32:52 GMT -8
I don't think a plugin would be able to access the LESS source file that we see in the Style Sheet via the Admin panel. But we could ask Brian , as I reckon he would know. A workaround was already suggested (though according to MDN it isn't compatible with IE), but I did want to explicitly state that this is the case and any CSS you add to a plugin can't use existing LESS variables nor does it ever go through the LESS compiler. IE is on the way out 🥳
|
|