CSSNEXT: how to use variables with media queries in CSS Next - postcss

I am trying to use variables to specify breakpoints using the CSSnext plugin.
Currently my css looks like this:
#media (width <= var(--screen-md-min)) {
background-color: var(--brand-purple-dark);
}
but when i try to run this I get the following warning in the console:
5: Missing #custom-media definition for '--screen-md-min'. The entire rule has been removed from the output.
This code works fine if I replace var(--screan-md-min) with actual pixels. I am sure this is just a problem with syntax, but the CSSnext documentation does not make the use of variables very clear.

cssnext only implements future-proof specifications.
And per specification, it's not possible to use custom properties (that' depends on the dom (:root is html) in a media query (that does not depend on the dom, but instead depends on the device).
However, people working on CSS specifications have thought about a solution for custom media queries. It's #custom-media.
#custom-media --small-viewport (width < 30rem);
#media (--small-viewport) {
/* styles for small viewport */
}
Some other informations
http://cssnext.io/features/#custom-media-queries
https://github.com/MoOx/postcss-cssnext/issues/253

Related

React Native End to End Tests with Detox: Getting height, width, and other properties of matched elements

As the title states, I would like to programmatically retrieve properties of matched elements in Detox. I know Detox sees them, because as we all infamously know when a toBeVisible expectation fails by the 75% view rule (a built in Detox opinion for the uninitated), we can see what detox 'got', usually it is a message something like this:
Got: "ReactTextView{id=13725, visibility=VISIBLE, width=376, height=102, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, layout-params=android.view.ViewGroup$LayoutParams#ac227fb, tag=PROFILE_NAME_TEXT, root-is-layout-requested=false, has-input-connection=false, x=486.0, y=120.0, text=Anonymous, input-type=0, ime-target=false, has-links=false}"
So we have things like the width, height, focus and so on.
My question is, how can we get at these properties programmatically? Specifically, I have an element that is expanding after a button tap and I want to be sure the height is larger than it was before.
If you check the methods available for element(by.id("SOME_ID")), there are only action methods available...
I've finally discovered the answer which was hard to find initial due to missing typings of detox at the time. Properties like height and width that I mentioned are available through getAttributes() method:
const attributes = await element(by.text('Tap Me')).getAttributes();
expect(attributes.text).toBe('Tap Me');
const multipleMatchedElements = await element(by.text('Multiple')).getAttributes();
expect(multipleMatchedElements.elements.length).toBe(5);
expect(multipleMatchedElements.elements[0].identifier).toBe('FirstElement');
The available properties vary between Android and iOS as well. See the documentation in the library for getAttributes(), and the pull request on detox which adds all the types.

Markdown File Unable To Process Unordered Lists Gatsby

I'm using Gatsby to build a new website. I'd like to render some markdown files for a blog, but it doesn't seem to be able to process the lists/unordered lists based on the markdown syntax. For instance, this is the syntax:
* Purple dots are points on the graph, each point has an x and y coordinate. These are your observed values
* Blue line is the prediction line, covering the estimated values of the model
* The red line between each purple point and the prediction line are the errors. Each error is the distance from the point to its predicted point.
This is the output:
I also found that it's not possible to use # for the headers. For instance, here's my post description and title:
_Making Use of the scipy.optimize Library in Python to Minimize Error_
## Revision
Output:
I'm not sure what I need to change within Gatsby to render the markdown correctly?
Your code is rendering properly the markdown file, however, you haven't added any style to make them look like an unordered list or as a header.
Just add your stylesheet file:
import './yourStyles.scss'
In yourStyles.scss:
h1 {
font-size: 3rem;
color: red;
}
ul {
list-style-type: default; // change it by desired value
}

Is there any way to change the text size (font size) of specific blocks when you using asciidoc?

I need your help.
Now I am using AsciiDoc and AsciiDoctor to create some manuals.
I want texts smaller on some specific blocks, for example wide table, wide list, and so on, but not want main texts smaller.
Especially I need to make texts of wide tables smaller as my customer requests so.
Is there any way?
You mention lists and tables...
About lists, it can't be done as stated in AsciiDoctor Documentation:
Unsupported
Complex AsciiDoc markup is not permitted in attribute values, such as:
lists
multiple paragraphs
other whitespace-dependent markup types
As you can see, there it mentions multiple paragraphs, so while #EhmKah answer is a correct way to set a custom styling block, it won't be rendered as expected in a table/list as it's multi-paragraph.
The Built-in CSS class syntax is the way to go [small]#any phrases#
But in order to make this work in a table, you must set the cell type with a specifier in this case, the AsciiDoc specifier denoted by a
This means the cell (or column) will render supported AsciiDoc statements, attributes, etc.
Here's a working example:
[frame="none",grid="none"]
|====
a| image::images\logo.png[] a|[.small]#Autor: {author}#
|====
If you have tons of rows/columns, you don't have to manually apply the a to all of them. You can set the columns you need this behavior this way:
[cols="1a,2a",frame="none",grid="none"]
|====
| image::images\logo.png[] |[.small]#Autor: {author}#
|====
You can check its documentation for more about Column Formatting and you can check the Rendered table with variable widths and alignments sub section for more about AsciiDoc (a) and other specifiers.
docinfo.html + --attribute docinfo=shared
You can drop your CSS modifications into a file called docinfo.html:
<style>
/* Your custom CSS. */
</style>
and then build with:
asciidoctor --attribute docinfo=shared README.adoc
and that makes Asciidoctor 2.0.10 place docinfo.html at the bottom of the <head> element.
So you can override most of the default Asciidoctor style from there.
Then it's just a matter of understanding the generated HTML and previous style definitions to override them.
For image specifically, see also: How to set a custom image height for an image in Asciidoctor?
When you use a theme file, you can add a role to it like this:
role:
mycustomfont:
font-color: #333
font-size: 10
Now you can reference your newly created role right from your table cell:
a|[.mycustomfont]# some text #
I read something about
[small] and [%autofit] option https://github.com/asciidoctor/asciidoctor-pdf/issues/185 I never needed it so maybe you give it a try.
example-code
[small]
----
should be rendered in smaller font.
----
[%autofit]
----
really long text that doesn't want to fit on a single line with the default font size, so we'll make it shrink to fit.
----

Create a static div to hold an advertisement in a Compass Susy grid?

I have to accomodate an MREC advertisement in my layout. The ad is 300pixels wide, and cannot resize as the fluid grid otherwise contracts.
Further, the ad needs to be the first item on smartphone, before the headline block. So, on the breakpoint I am setting it to omega to push it "after" the headline, as in this screenshot (gray rules just to make it easier to see).
The headline is 8 cols, the ad is 4. All is fine except on ipad the ad column and the ad reduces to under 300 pixels, which we are not allowed to do. So, how to keep everything fluid except the ad container?
Set max/min widths on the container?
This is not hard to do, but it means the grid up top won't exactly match the flexible grid below. I assume that isn't an issue. You have to use some functions to lay out these two elements, but everything else can be done exactly as it was before.
You can keep the ad flexible down to a minimum width:
.ad {
#include span-columns(4 omega);
min-width: 300px; // you can use any width you want.
}
Or you can make the ad completely static:
.ad {
float: right;
width: columns-width(4); // you can use any width you want.
}
The important part is that you must not set a column width on the headline.
You have a few other options. The simplest might be to set right margins and padding equal to the static ad size (plus gutter):
.headline {
margin-right: columns-width(4) + $gutter-width;
}
Or, if you want that gutter to flex, try:
.headline {
margin-right: columns-width(4);
padding-right: gutter();
}
You can add clear: both; to the main content to make sure it clears the headline and ad.
If this approach doesn't work for you, try creating a new "formatting context" for the headline. One of the classic techniques is simply overflow: hidden;. Nicole Sullivan has a good blog post on how they do it for oocss, but it gets a bit more complex and you may not need all that.
UPDATE:
All these solutions require the ad coming first in the markup. The only way around that is if you know the height of the ad. In that case, you could position the ad absolutely rather than floating it, create space for it in the same way, and set a min-height on the headline (or row-container if you have one).

What is a bad selector?

In the error console concerning a math lab program, there is a continuous error reporting about a bad selector. What is a bad selector?
A selector, generally, is a label / path to a code element. For example, in CSS, to style any paragraphs within a container div with id="container", the selector is
#container p, where # just means 'id'. I imagine in other languages it means something similar - the program is looking for an element but can't find the one it's been told to, so it throws the error.

Resources