Nested / Compounded roles: apply multiple roles to overlapping text - python-sphinx

In my custom.css file I have,
.bold {
font-weight: bold;
}
.red {
color:red;
}
And in my _.rst file,
.. role:: bold
.. role:: red
But if I try to nest/compound them, only the outermost role takes effect, e.g.
:bold:`:red:`This is only bold``
This is only bold
Is there a way to combine these effects without defining a new (combined) role?

you can use a custom css class directive:
.. cssclass:: boldred
bold red text
and update the css to format the boldred class

Roles are defined that the can not be nested.
Neither HTML nor LaTeX, as backends, support overlapping of styles.

Related

Avoid duplication for color schemes when it's only the value of a property that changes

I have elements throughout my application that can have one of three colors.
Right now I put a class on each element .color1, .color2 or .color3.
And then in the css declerations I do like the following (depending on element):
.color1 .special_element {background-color: $color1;}
.color2 .special_element {background-color: $color2;}
.color3 .special_element {background-color: $color3;}
The above pattern is repeated many times.
Is there any way to make the code above more dense, e.g. with some sort of conditional and argument?

Sass with compas, selecting all divs with x class before hyphen

I am using Sass and currently selecting my divs via:
[class*='inner-']{
padding: $pad;
}
But i have two variants of this div which are: -left, -right but i wanted to see if there was a better way rather than doing individual style blocks for each one, if i could merge it into one block.
My variants have a slight variation on the padding.
So something like:
[class*='inner-']{
padding: $pad;
-left{
atttribute
}
-right{
attribute
}
}
I might be over thinking this and making it pointlessly complex, but it's helping me learn lots so if anyone can shed some light on the best solution I'd appreciate it.
Not sure I've understood what you need properly, but I think you making it too complex.
Nice and simple solution:
%inner {
padding: somepadding;
}
.inner-left {
#extend %inner;
some other: attributes for left;
}
.inner-right {
#extend %inner;
some other: attributes for right;
}
We use placeholder (%inner), it's like a silent class, won't be outputed until called. Then extend it to those two classes. Nice, clean and maintainable solution.

Naming Color Variables in SASS

When creating a color scheme in SASS what's the conventional variable names for defining colors?
I know using color names are bad. Such as:
$blue
$red
$green
But I've not seen an alternative. I'm struggling for variable names for colors on the site that convey meaning.
Any ideas?
I found another idea in "SASS & Color Variables" article. The solution suggested by Sacha Greif is to use some variables to store descriptive color names, and some other to assign those colors to their functions:
// first we set descriptive variables:
$darkgrey: #333333;
$blue: #001eff;
// then we set functional variables:
$text_color: $darkgrey;
$link_color: $lightblue;
$border_color: $lightblue;
.myClass {
color: $text_color;
border-color: $border_color;
}
a {
color: $link_color;
}
I'm just beginning with SASS and don't know which approach is more practical, but I like the way it separates colors from their function.
In my personal experience the most useful way to name colors is to do it in regards of the color's function, such as
$background
$contrast
$text
$aside
$link
And so on. Of course which colors and name may depend on the design.
Then you may have different and exchangeable color schemes defined on different styles, such as:
_dark_scheme.scss
_light_scheme.scss
_pastels.scss
The idea here, is that you can use the same color variables in your main stylesheets, and do not depend on specific colors.
I like the idea of combining generic to specific naming (good for code completion) and description/functional naming. So you have something like this:
// Descriptive naming
$color-gray-light: #f3f3f3;
$color-gray-dark: #999999;
$color-red: red;
// Functional naming
$link-color: $color-red;
$link-border-color: $color-gray-light;
You can even create a mixin for greys (in the example RGBA is used for transparency, for example black on a red background would be more visible if it is 80% transparent black rather than dark grey).
#mixin grey($intensity: 0.5, $type: color) {
#{$type}: rgba(black, $intensity);
}
.i-am-50-percent-gray {
#include grey(0.5, color);
}
Give the result
.i-am-50-percent-gray {
color: rgba(0, 0, 0, 0.5);
}

Check if SASS parent selector exists. Is it possible

I have a question. So in a mixing I am making a reference to the parent selector "&". This works as long as the mixin is not nested. Is there a way to to detect if the mixing is being used in a non nested scenario, or to check if "&" is null?
This works when the mixin call is not nested
=myresponsiveMixin($media)
#if $media == small {
#media only screen and (max-width: $break-small)
#content
#else if $media == medium
#media only screen and (min-width: $break-small + 1) and (max-width: $break-large - 1)
#content
This works great when the mixin call is nested, but will not resolve '&' when not nested
=myresponsiveMixin($media)
#if $media == small {
#media only screen and (max-width: $break-small)
.classInHTMLToAllowMediaQueries &
#content
#else if $media == medium
#media only screen and (min-width: $break-small + 1) and (max-width: $break-large - 1)
.classInHTMLToAllowMediaQueries &
#content
So the question is, if there is a way to be able to check the value of parent selector "&", so I can cover all bases in a single mixin?
#mixin does-parent-exist {
#if & {
.exists & {
color: red;
}
} #else {
.doesnt-exist {
color: red;
}
}
}
http://sass-lang.com/documentation/file.SASS_REFERENCE.html#parent-script
You're trying a wrong solution to solve your issue.
Have a look at how this problem is addressed in powerful SASS frameworks. Let's take Susy by Eric Meyer as a great example.
Let's imagine you've got the following HTML:
<div class="container">
<div class="parent">
<div class="child">
Bla bla
</div>
</div>
</div>
When you call a mixin for the first time, you're doing it simply (the code is in the indented .sass syntax):
$total-columns: 8 // Declaring a varible that will be used by the mixin
.parent
+span-columns(4) // Span four of eight columns
But when you call that for a child element, the proportions would be crooked, because the parent is already proportioned:
.child
+span-columns(2) // This will fail. You want 2 of 8 columns,
// but due to nesting the math is crooked.
// It will be "2 of (4 of 8)".
To address the issue, you provide an optional argument: a context that is used to do the math:
.child
+span-columns(2, 4) // Now the mixin will take 2 parts of 4
// instead of 2 parts of four
The source code for this mixin is available on GitHub.
In short, it creates an optional argument like this (the code is in the CSS-like .scss syntax):
#mixin span-columns(
$columns,
$context: $total-columns
//...
) {
//...
width: columns($cols, $context /*...*/);
//...
}
See how $context has a default value? Thanks to the default value this argument can be omitted. In other words, $context is an optional argument.
When calling this mixin, if $context is not provided (e. g. span-columns(2)), then it is set equal to $total-columns. The $total-columns variable should be set prior to calling the mixin for the first time (see my example above).
Then the two arguments are used to calculate the width.
UPD 2013-03-30
I am not trying to figure out things in regards to columns... I have modifier my question to make it clearer.
First of all, my recommendation concerns not only grid columns. It's a universal technique you can adopt.
Secondly, now i see that you're trying to nest media queries.
Well, some media queries of different type can be combined in CSS3: e. g. print and width. But you can't put a min-width: 601px inside max-width: 600px, this just won't work!
There's an extensive answer here on StackOverflow describing why you should not nest media queries of the same type: https://stackoverflow.com/a/11747166/901944
Thirdly, you're trying to invent the wheel. There's already a fantastic mixin for crunching media queries: Respond To by Snugug. It's super easy to use and very effective.
Fourthly, the XY thing. Instead of asking about your crooked mixin, please describe the problem that you're trying to solve with it! Show us the actual HTML and explain what behavior you would like to achieve.
We will show you that it can be solved with a simple, elegant, semantic solution that does not require SASS hacking.

Flex 4 change popup's overlay color

How can I change the color or the transparency of the popup's overlay? I want to have another color and alpha 1.
http://mprami.wordpress.com/2008/04/22/alert_popup_modal_transparancy_color_blur_changes/
In flex ‘’ tag has mainly four attributes related to modal properties of pop-ups.
modalTransparency
modalTransparencyBlur
modalTransparencyColor
modalTransparencyDuration
In spark it looks like these were renamed slightly:
modal-transparency
modal-transparency-color
modal-transparency-duration
modal-transparency-blur (guessing on this one)
To extend on artjumble's answer, if you're using a css file, you can also declare it like that in the css file:
global {
modalTransparencyBlur: 0;
modalTransparency: 0.3;
modalTransparencyColor: black;
modalTransparencyDuration: 500;
}

Resources