Blueprint.js dynamic $ns variable in scss - sass

I'm using Blueprint.js v3.x and have been making use of the SASS variables. I want to leverage the $ns variable, but my app is in dark mode. The $ns variable is set to bp3 !default; on line 10 of the file above, which from what I understand means I can set it to a different value in my app.scss. It would be fine, then, to just set $ns: bp3-dark; and use this variable that way. However, in the future I want to support a dark/light mode switch; how can I, following best practice, dynamically set $ns to be the correct value based on said switch?

After further consideration, it seems that I am not entirely clear on the fundamentals of why the $ns variable exists: rather than trying to use it to reference whether the app is in dark or light mode, it makes more sense to use it thus (SCSS):
.app {
.#{$ns}-dark {
/* set the background color, any other required setup */
...
& .my-button-group.#{$ns}-button-group {
/* override anything you might want for the element.bp3-button-group
}
}
}
Essentially, the $ns variable is used to point to bp3 to allow for future-proofing of your SASS. Changing it to bp3-dark or any other value would defeat this purpose.

Related

How to display debug info or console.log equivalent in Lua

I am creating many games using Lua and LOVE2D, but whenever I implement a new function and want to test it out, or simply want to know a value of a variable in Lua, I either display it on the game screen or just hope that it works.
Now my question is...
IS THERE A WAY TO DISPLAY SOME INFO, such as A VARIABLE VALUE or something else into the terminal or somewhere else? Just like console.log in javascript which displays some content in the javascript console in the browser. So, is there a way to do this is Lua?? using LOVE2D?
I am using a Mac, so I have a terminal and not a command prompt. Is there a way to display some content there? Anywhere else would also be fine, I just need to see if those values are as expected or not.
Use a conf.lua file to enable the console, then you should be able to use a standard print(). You can read the wiki entry here.
Note: You have to run Lua and Love2D via the terminal for this to work. Running Lua and Love2D like this is required for the print statements to show:
/Applications/love.app/Contents/MacOS/love "/Users/myuser/Desktop/love2d-test-proj"
You just need to add a conf.lua file to the same location where your main.lua. Your file may be as simple as this:
function love.conf(t)
t.console = true
end
But feel free to copy the whole configuration file from the above link and edit what you need.
I can't be completely sure about this, because I have no access to Mac, but the console is disabled by default and even on Windows, no prints are shown until you turn it on.
Alternatively You can also display debug info in the game itself like some games do.
What I like to do is add something like debugVariable = {} for logging events that happen in each loop and debugPermanent = {} for events that happen rarely. Possibly add convenience functions for writing to the variables:
function debugAddVariable(str)
table.insert(debugVariable, str)
end
--..and similarly for debugPermanent
Now a function to draw our debug info:
function debugDraw()
love.graphics.push() --remember graphics state
love.graphics.origin() --clear any previous transforms
love.graphics.setColor(--[[select color for debug info]])
love.graphics.setFont(--[[select font for debug info]])
for i, v in ipairs(debugPermanent) do
love.graphics.print(v)
love.graphics.translate(0, --[[fontHeight]])
end
for i, v in ipairs(debugVariable) do
love.graphics.print(v)
love.graphics.translate(0, --[[fontHeight]])
end
debugVariable = {} --clear debugVariable to prepare it for the next loop
love.graphics.pop() --recall graphics state
end
And we just call this draw function at the end of our love.draw() and the texts should appear.
Obviously, this method can be refined further and further almost infinitely, displaying specific variables, and adding graphs for some other variables to clarify the information you want to show, but that's kind of outside of the scope of the question.
Lastly Feel free to check here for debug libraries submitted by users.

Disable 'no-duplicate-dollar-variables' for variables declared as !default

A code snippet dealing with the scenario:
$unfolded-transitions: () !default;
#each $transition in $transitions {
$unfolded-transitions: append($unfolded-transitions, unfoldTransition($transition), comma); /* stylelint-disable-line scss/no-duplicate-dollar-variables */
}
Here I have explicitly used stylelint-disable-line comment to skip the rule. Is it possible to tell stylelint to skip the 'no-duplicate-dollar-variables' rule when a variable is initialized with default as in the case above. In case if a value is assigned to a variable, then stylelint should report the required warning if there are duplicates.
Is it possible to tell stylelint to skip the 'no-duplicate-dollar-variables' rule when a variable is initialized with default as in the case above
It is not possible but it should be.
I recommend you create a new issue in the stylelint-scss tracker and suggest that the no-duplicate-dollar-variables rule takes into account !default variables.

Can Firefox's User.js file have conditional user_pref() statements?

Is it possible to create a conditional user_pref() in Mozilla Firefox user.js?
I have tried using an if-else statement, but the contents of the first if statement is executed, even if the given condition is false. The contents of the else statement is ignored.
Example #1:
if ( false )
{
// This is executed even though the given condition is false in Mozilla Firefox user.js.
user_pref( 'browser.display.background_color', '#000000' );
}
else
{
// Unfortunately, this is not executed in Mozilla Firefox user.js.
user_pref( 'browser.display.background_color', '#FFFFFF' );
}
Additionally, I have also tried using a ternary expression to conditionally change a user preference, but the expression is skipped entirely.
Example #2:
// This is not executed at all in Mozilla Firefox user.js.
user_pref( 'browser.display.background_color', ( 1 === 2 ? '#000000' : '#FFFFFF' ) );
Overall, I am trying to eventually find a way to change user_pref() properties conditionally depending on the contents of window.location.href.
Reference the documentation for Firefox's User.js file. Nowhere does it claim that the file takes javascript or any other (Turing complete) programming language.
The file takes either comments or user_pref() lines only.
So, conditional statements are not allowed.
However, since you are modifying styles in your example, you can accomplish the same thing with user style CSS and/or the Stylish add-on (recommended). There you can use some logic, based on the domain and/or URL.
For logic about other, non-style, prefs, you might be able to write an extension to do what you wish.
First of all are you sure you want to use === and not ==? Remember === uses a strict conversion and not just typecasting so in most cases == will work fine.
Additionally if you are setting some sort of background color of theme it is better to use that data directly instead of just setting it in a preference setting (i.e. storing the value in a variable then storing that in the user.js preference setting).

How does the $grid-column-alias Sass variable work...?

Setting it to false is supposed to utilize only "column", but in my project it has no impact in the compiled CSS -- both column and columns are still there.
I'm interested in getting it to work because the Foundation 6 grid documentation indicates it will reduce file size by 3 to 5%. I have tried all of the following and none have produced the desired result:
// Selector used for an alias of column (with #extend). If false, no alias
is created.
$grid-column-alias: '';
$grid-column-alias: 'false';
$grid-column-alias: false;
$grid-column-alias: 'column';
Has anyone else used this successfully? I'm declaring it with my other grid-column variables. What am I missing?
Looking at the source code here https://github.com/zurb/foundation-sites/blob/develop/scss/grid/_classes.scss#L170 it appears that it is checking for
#if $column == 'column' and has-value($grid-column-alias)
has-value returns false for anything falsy, so this implies setting $grid-column-alias to false should work... testing it quickly in an empty ZURB template I see that when I update my _settings.scss to have $grid-column-alias: false; I no longer get .columns classes.
If this isn't working for you, perhaps you're setting it after you've already included the mixin? If you could explain a little more about your scss and build setup perhaps that would help track this down.

Cocoa app Bash Script Variables

I would like to reference a variable that I have in a bash script "value" as well as "max." As of now, I have a text interface in which after given commands, the terminal window displays something similar to
==========================================================================> 100%
for a progress bar. The variable is referenced throughout the script, and I would like to call that variable in my cocoa app.
Thanks in advance!
Your question isn't entirely clear, but it sounds like you want to use environment variables. In bash, you need to use the export builtin to mark a variable to be exported to child processes. Then, in your Cocoa app, you can use getenv(3) function to retrieve the environment variable value. For example:
# In your bash script
value=foo
max=bar
export value max
// Now in your Cocoa application:
char *value;
if((value = getenv("value")))
{
// Use value
}
// else value is not in the environment

Resources