Is there any way to join stylus partials without actually compiling them? - stylus

Is there any way to join stylus partials without actually compiling them? I guess this would be the same as .SCSS files - so then it's a question of build tools. In codekit - you can join javascript files in this way / but that is because it's not a superset style language. I currently use broccoli or brunch depending on the stack, for my builds. I am not interested in trying any other build tools right now.
_thing-1.styl
html
background: blue
_thing-2.styl
div
background: red
_thing-3.styl
span
color: yellow
app.styl
#import '_thing-1'
#import '_thing-2'
#import '_thing-3'
app.css
html {
background: blue;
}
div {
background: red;
}
span {
color: yellow;
}
and... THIS is what I want to have as well...
_master.styl
html
background: blue
div
background: red
span
color: yellow
Any ideas?

I think, this question is more about build tools and not Stylus itself, something like gulp.concat or simple cat _thing-1.styl _thing-2.styl _thing-3.styl > _master.styl

Related

Can't get #media queries to work when overriding bootstrap 4 using React Bootstrap

Basically, using bootstrap 4, i'm trying to take the bootstrap class "custom-select" and override some of the bootstrap elements for my own uses. Here's the html and scss im using. Pretty simple stuff imo.
<select className="custom-select" id='sortingSelect' onChange={(e) => setSortingOption(e.target.value)}>
<option defaultValue value ="0">Random</option>
<option value="1">A - Z</option>
<option value="2">Z - A</option>
</select>
.custom-select#sortingSelect{
width: 5% !important;
float: right !important;
margin-right:5% !important;
}
It straight up would not work when i put it in the "module.scss" for that page i was working on, so i ended up having to put it into my custom.scss that globally overrides stuff. Even when using !important tags, it still wouldn't work in my module.scss, but it does work with my custom.scss. That's problem solved, well, kind of.
Because! I want it to also be able to change with screen size, this is bootstrap after all. So i put the following into my custom.scss
#media (max-width: 768px) {
.custom-select#sortingSelect{
float: none !important;
display: block !important;
margin: 0 auto !important;
}
}
It doesn't even seem to recognize this input at all for some reason :/
Are media queries simply just not allowed in the custom.scss file? If that's the case am i just boned? Or am i just going about this all wrong? It could be some issue with specificity, but how the heck do i get more specific than what ive already got?
Please lemme know if i need to provide more context!
Also! I read that i need to include the following code in my html
<meta content="width=device-width, initial-scale=1" name="viewport" />
However, i am using React, so i included it in the html that is returned from my Layout component that renders everything else, still no luck, and that wouldn't make sense as the problem anyhow, because media queries have worked before in that very same file, just not with overriding bootstrap stuff. Overriding bootstrap stuff always seems to be way more difficult than it needs to be in my experience so far.
Edit: I tried using bootstraps built in break points, but that failed as well
Why are you using both class and ID at the same time in your CSS file.
Either use className or Id for CSS.
Like:
.custom-select{
width: 5% !important;
float: right !important;
margin-right:5% !important;
}
OR
#sortingSelect{
Height: 5% !important;
float: left !important;
margin-left: 5% !important;
}

How to use Google fonts in React.js?

I had built a website with React.js and webpack.
I want to use Google fonts in the webpage, so I put the link in the section.
Google Fonts
<link href="https://fonts.googleapis.com/css?family=Bungee+Inline" rel="stylesheet">
And set CSS
body{
font-family: 'Bungee Inline', cursive;
}
However, it does not work.
How can I solve this problem?
In some sort of main or first loading CSS file, just do:
#import url('https://fonts.googleapis.com/css?family=Source+Sans+Pro:regular,bold,italic&subset=latin,latin-ext');
You don't need to wrap in any sort of #font-face, etc. the response you get back from Google's API is ready to go and lets you use font families like normal.
Then in your main React app JavaScript, at the top put something like:
import './assets/css/fonts.css';
What I did actually was made an app.css that imported a fonts.css with a few font imports. Simply for organization (now I know where all my fonts are). The important thing to remember is that you import the fonts first.
Keep in mind that any component you import to your React app should be imported after the style import. Especially if those components also import their own styles. This way you can be sure of the ordering of styles. This is why it's best to import fonts at the top of your main file (don't forget to check your final bundled CSS file to double check if you're having trouble).
There's a few options you can pass the Google Font API to be more efficient when loading fonts, etc. See official documentation: Get Started with the Google Fonts API
Edit, note: If you are dealing with an "offline" application, then you may indeed need to download the fonts and load through Webpack.
Google fonts in React.js?
Open your stylesheet i.e, app.css, style.css (what name you have), it doesn't matter, just open stylesheet and paste this code
#import url('https://fonts.googleapis.com/css?family=Josefin+Sans');
and don't forget to change URL of your font that you want, else working fine
and use this as :
body {
font-family: 'Josefin Sans', cursive;
}
If you are using Create React App environment simply add #import rule to index.css as such:
#import url('https://fonts.googleapis.com/css?family=Anton');
Import index.css in your main React app:
import './index.css'
React gives you a choice of Inline styling, CSS Modules or Styled Components in order to apply CSS:
font-family: 'Anton', sans-serif;
you should see this tutorial: https://scotch.io/#micwanyoike/how-to-add-fonts-to-a-react-project
import WebFont from 'webfontloader';
WebFont.load({
google: {
families: ['Titillium Web:300,400,700', 'sans-serif']
}
});
I just tried this method and I can say that it works very well ;)
Here are two different ways you can adds fonts to your react app.
Adding local fonts
Create a new folder called fonts in your src folder.
Download the google fonts locally and place them inside the fonts folder.
Open your index.css file and include the font by referencing the path.
#font-face {
font-family: 'Rajdhani';
src: local('Rajdhani'), url(./fonts/Rajdhani/Rajdhani-Regular.ttf) format('truetype');
}
Here I added a Rajdhani font.
Now, we can use our font in css classes like this.
.title{
font-family: Rajdhani, serif;
color: #0004;
}
Adding Google fonts
If you like to use google fonts (api) instead of local fonts, you can add it like this.
#import url('https://fonts.googleapis.com/css2?family=Rajdhani:wght#300;500&display=swap');
Similarly, you can also add it inside the index.html file using link tag.
<link href="https://fonts.googleapis.com/css2?family=Rajdhani:wght#300;500&display=swap" rel="stylesheet">
(originally posted at https://reactgo.com/add-fonts-to-react-app/)
In your CSS file, such as App.css in a create-react-app, add a fontface import. For example:
#fontface {
font-family: 'Bungee Inline', cursive;
src: url('https://fonts.googleapis.com/css?family=Bungee+Inline')
}
Then simply add the font to the DOM element within the same css file.
body {
font-family: 'Bungee Inline', cursive;
}
Another option to all of the good answers here is the npm package react-google-font-loader, found here.
The usage is simple:
import GoogleFontLoader from 'react-google-font-loader';
// Somewhere in your React tree:
<GoogleFontLoader
fonts={[
{
font: 'Bungee Inline',
weights: [400],
},
]}
/>
Then you can just use the family name in your CSS:
body {
font-family: 'Bungee Inline', cursive;
}
Disclaimer: I'm the author of the react-google-font-loader package.
Had the same issue. Turns out I was using " instead of '.
use #import url('within single quotes'); like this
not #import url("within double quotes"); like this
I can see there are various different ways to include google fonts in react app. Let's explore the most preferred and optimum way.
#import vs link
The two options that google font provides are using link and #import. So now the question directs toward decision in between #import and link. There is already a Stack Overflow question regarding this comparison and here is a reference from the accepted answer
<link> is preferred in all cases over #import, because the latter
blocks parallel downloads, meaning that the browser will wait for the
imported file to finish downloading before it starts downloading the
rest of the content.
So, it's most preferable to use the link tag that google font provides
How to use link and why in a react app?
I have seen few answers giving this method as a solution but I want to make it more clear why it is most preferable.
After using create-react-app to initialize the project, you can see a comment in the index.html file inside the public folder as below.
You can add webfonts, meta tags, or analytics to this file. The build step will place the bundled scripts into the tag.
So you can simply include the link tag that google font provides in the head section of the above file.
<link href="https://fonts.googleapis.com/css?family=Bungee+Inline" rel="stylesheet">
Then you can use it in the CSS file and import in JSX
font-family: 'Bungee Inline', cursive;
In case someone needs it, you can use #fontsource. They have all of the Google Fonts and seems easier than most of the solutions here.
If anyone looking for a solution with (.less) try below. Open your main or common less file and use like below.
#import (css) url('https://fonts.googleapis.com/css?family=Open+Sans:400,700');
body{
font-family: "Open Sans", sans-serif;
}
Edit index.css
#import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wght#0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap");
body {
margin: 0;
font-family: "Poppins", sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
I added the #import and the #font-face in my css file and it worked.
Add link tag in index.html on root directory inside public folder.
<link href="https://fonts.googleapis.com/css?family=Bungee+Inline" rel="stylesheet"/>
then use it in any css file.
Create a new folder fonts in your src folder.
Download the google fonts locally and place them inside the fonts folder.
Open your index.css file and include the font by referencing the path.
#font-face {
font-family: 'Roboto';
src: local('Roboto'), url(./fonts/Roboto/Roboto-Regular.ttf) format('truetype');
}
now you can use font link this
.firstname{
font-family: Roboto, serif;
color: #0004;
}
It could be the self-closing tag of link at the end, try:
<link href="https://fonts.googleapis.com/css?family=Bungee+Inline" rel="stylesheet"/>
and in your main.css file try:
body,div {
font-family: 'Bungee Inline', cursive;
}
In some cases your font resource maybe somewhere in your project directory.
So you can load it like this using SCSS
$list: (
"Black",
"BlackItalic",
"Bold",
"BoldItalic",
"Italic",
"Light",
"LightItalic",
"Medium",
"MediumItalic",
"Regular",
"Thin",
"ThinItalic"
);
#mixin setRobotoFonts {
#each $var in $list {
#font-face {
font-family: "Roboto-#{$var}";
src: url("../fonts/Roboto-#{$var}.ttf") format("ttf");
}
}
}
#include setRobotoFonts();

How to highlight contents of parenthesis in Atom

I have just started to use Atom editor these days. Before that, I have used python IDLE. IDLE highlight the contents of parenthesis for us when we just created parenthesis. But, Atom does not.
Do you know any themes or packages to make it possible in Atom?
You can use this selector: atom-text-editor .bracket-matcher .region, :host .bracket-matcher .region to highlight the brackets any way you want.
For example:
atom-text-editor .bracket-matcher .region,
:host .bracket-matcher .region {
border-bottom: none;
background: red;
}
This will make the brackets have a bright red highlight.
You can try Material Theme, I'm using it and parenthesis is auto-created. Another choice is to install a package named BracketHighlighter.

Avoiding page break in pdf generation with salesforce

I must remove page break while generating pdf by visual force pdf, but whatever I try with css page-break-inside: avoid;, page-break-before: avoid; etc. is not working.
I want to remove all page breaks making it a continuous pdf page, but I cannot figure it out.
Instead of using CSS styling for the APEX component, try a div tag around the APEX components you want to not be broken apart with style="page-break-inside:avoid;"
//div style="width:100%;page-break-inside:avoid;"> APEX ///div>
This css page-break-inside: avoid;, page-break-before: avoid; works only when you need to iterate on components. If you are using inline pre-built css into page then you have to check following css related to body tag. like this:
body { box-sizing: border-box; height: 11in; margin: 0 auto; overflow: hidden; padding: 0.5in; width: 8.5in; }
Here I am using width and height with auto value.

css to remove text shadow on select / highlight text (mozilla)

I'm using text shadows for most text site wide, but when you highlight / select the text - the text looks fuzzy. So in order to remove the text shadow I use this css from here.
::-moz-selection,
::-webkit-selection,
::selection {
text-shadow: none;
background: #333;
color: #fff;
}
The problem is that for some reason moz-selection doesn't seem to work (anymore?) in mozilla (Firefox).
Here's the jsFiddle
It seems like the problem was due to grouping multiple css rules (for the vendor specific css) together in conjuntion with the ::selection pseudo element.
I originally thought that it was sufficient to write each statement on a separate line.
I was mistaken.
So if I replace this code:
::-moz-selection,
::selection {
text-shadow: none;
background: #333;
color: #fff;
}
..With this code:
::-moz-selection
{
text-shadow: none;
background: #333;
color: #fff;
}
::selection {
text-shadow: none;
background: #333;
color: #fff;
}
.... bingo, it works.
FIDDLE
Support is also very good (for desktop): Caniuse
Also, if you use LESS or SASS - you could easily write a mixin to get around the repitition.
The following is documented on Mozilla Developer Network:
Though this pseudo-element was in drafts of CSS Selectors Level 3, it was removed during the Candidate Recommendation phase, as it appeared that its behavior was under-specified, especially with nested elements, and interoperability wasn't achieved (based on discussion in the W3C Style mailing list).
The ::selection pseudo-element currently isn't in any CSS module on the standard track. It should not be used in production environments.

Resources