All Projects → iamstarkov → css-initials

iamstarkov / css-initials

Licence: other
initial CSS values to use in `all: initial` polyfils

Programming Languages

CSS
56736 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to css-initials

Box Shadows.css
♓️ A cross-browser collection of CSS box-shadows
Stars: ✭ 335 (+371.83%)
Mutual labels:  cross-browser
React Stickyroll
A react implementation of stickyroll (original)
Stars: ✭ 132 (+85.92%)
Mutual labels:  cross-browser
Scroll Js
Light cross-browser scroller that uses native javascript
Stars: ✭ 179 (+152.11%)
Mutual labels:  cross-browser
Zebra datepicker
A super-lightweight, highly configurable, cross-browser date / time picker jQuery plugin
Stars: ✭ 367 (+416.9%)
Mutual labels:  cross-browser
Cbt Tunnel Nodejs
Node.js module for Local Connections to crossbrowsertesting.com
Stars: ✭ 39 (-45.07%)
Mutual labels:  cross-browser
Jqueryrotate
jQueryRotate - plugin to rotate images by any angle cross-browse with animation support
Stars: ✭ 157 (+121.13%)
Mutual labels:  cross-browser
Input Range Scss
Styling Cross-Browser Compatible Range Inputs with Sass
Stars: ✭ 272 (+283.1%)
Mutual labels:  cross-browser
universalSmoothScroll
A cross-browser smooth-scrolling API which supports multiple and interruptable scroll-animations on all DOM's elements, even at the same time!
Stars: ✭ 46 (-35.21%)
Mutual labels:  cross-browser
Morphist
A simple, high-performance and cross-browser jQuery slider / slideshow / carousel plugin for child objects powered by Animate.css.
Stars: ✭ 60 (-15.49%)
Mutual labels:  cross-browser
Restyle
Stars: ✭ 171 (+140.85%)
Mutual labels:  cross-browser
Morphext
A simple, high-performance and cross-browser jQuery rotating / carousel plugin for text phrases powered by Animate.css.
Stars: ✭ 384 (+440.85%)
Mutual labels:  cross-browser
Web Extension Starter
🖥🔋Web Extension starter to build "Write Once Run on Any Browser" extension
Stars: ✭ 987 (+1290.14%)
Mutual labels:  cross-browser
Ifvisible.js
Crossbrowser & lightweight way to check if user is looking at the page or interacting with it.
Stars: ✭ 1,896 (+2570.42%)
Mutual labels:  cross-browser
Hprose
HPROSE is short for High Performance Remote Object Service Engine. It's a serialize and RPC library, the serialize library of hprose is faster, smaller and more powerful than msgpack, the RPC library is faster, easier and more powerful than thrift.
Stars: ✭ 348 (+390.14%)
Mutual labels:  cross-browser
Store.js
Cross-browser storage for all use cases, used across the web.
Stars: ✭ 13,656 (+19133.8%)
Mutual labels:  cross-browser
T Shirts
The first OpenSource t-shirts (probably)
Stars: ✭ 300 (+322.54%)
Mutual labels:  cross-browser
Hprose Js
Hprose is a cross-language RPC. This project is Hprose 2.0 RPC for JavaScript
Stars: ✭ 133 (+87.32%)
Mutual labels:  cross-browser
reason-cookie
A simple way to use cookies in Reason (OCaml) on the frontend. 🍪
Stars: ✭ 18 (-74.65%)
Mutual labels:  cross-browser
Hprose Html5
Hprose is a cross-language RPC. This project is Hprose 2.0 Client for HTML5
Stars: ✭ 237 (+233.8%)
Mutual labels:  cross-browser
Vue Warehouse
A Cross-browser storage for Vue.js and Nuxt.js, with plugins support and easy extensibility based on Store.js.
Stars: ✭ 161 (+126.76%)
Mutual labels:  cross-browser

css-initials

Initial CSS values for all: initial polyfills.

Table of Contents

Usage

Vanilla css

Import all.css or inherited.css file and add the class initials-all or initials-inherited to an element you want to have initial values.

/**
 * On the very top of your ./styles/main.css
 */
 @import './css/css-initials.css';

/*
 * Those properties depend on a browser and user settings. You can reset them manually
 * if you want them to behave consistently.
 */
.initials-all {
  font-family: Arial, "sans-serif";
  text-align: left;
  quotes: "“" "”" "‘" "’";
  color: black;
  outline-color: black;
}

/* user styles here */

.button {
  /* …more user styles here…*/
}

In HTML, just add css-initials class in the start

<button class="initials-all button">Submit</button>

css-modules

/**
 * Once in your project, specify your
 * ./src/components/app-css-initials/index.css
 */
.app-css-initials {
  composes: css-initials from 'css-initials/index.css';

  font-family: Arial, "sans-serif";
  text-align: left;
  quotes: "“" "”" "‘" "’";
  color: black;
  outline-color: black;
}

/**
 *  Anywhere after in your components
 *  ./src/components/button/index.css
 */
.button {
  composes: app-css-initials from './app-css-initials.css';
  /* …more user styles here…*/
}

css-in-js

JSS

import cssInitials from 'css-initials';
import jss from 'jss';
import preset from 'jss-preset-default';

jss.setup(preset());

const myCssInitials = Object.assign({}, cssInitials, {
  fontFamily: 'Arial, sans-serif',
  textAlign: 'left',
  quotes: '"“" "”" "‘" "’"',
  color: 'black',
  outlineColor: 'black',
});

const sheet = jss.createStyleSheet({ initials: myCssInitials }).attach();

const {classes} = jss.createStyleSheet({
  button: {
    composes: sheet.classes.initials,
    background: 'blue',
  }
}).attach();

document.body.innerHTML = `
  <button class="${classes.button}">Button</button>
`;

styled-components

// Once in your project, specify your
// ./src/components/app-css-initials/index.js
import cssInitials from 'css-initials';

const toCSS = obj => Object.keys(obj).map(key => `${key}: ${obj[key]};`).join('\n');

export default `
  ${toCSS(cssInitials)}
  font-family: Arial, 'sans-serif';
  text-align: left;
  quotes: "“" "”" "‘" "’";
  color: black;
  outline-color: black;
`;

// Anywhere after in your components
// ./src/components/button/index.js
import React from 'react';
import styled from 'styled-components';
import initials from '../app-css-initials';

const Button = styled.button`
  ${initials}
  display: inline-block;
  border-radius: 5px;
  /* …more styles here…*/
`;

export default Button;

FAQ

What is wrong with the usual all: initial?
—It's not supported in IE, Edge, Mobile android.

What do you mean by cross-browser?
—I took all properties and combined 'em with their initial values, so it works in every browser, because its essentially all: initial, but expanded.

What do you mean by thoughtful?
—There are several caveats about all: initial as it is now, and I have built this package with those caveats in mind.

What are the caveats?
— 1) Initial values of font-family, quotes and color depend on the browser
— 2) 14 properties depend on currentColor, which is a reference to the color property, which varies from browser to browser (hence prev point), and these properties are: -webkit-border-before-color, -webkit-text-fill-color, -webkit-text-stroke-color, border-block-end-color, border-block-start-color, border-bottom-color, border-inline-end-color, border-inline-start-color, border-left-color, border-right-color, border-top-color, column-rule-color, text-decoration-color, text-emphasis-color.
— 3) Initial value of outline-color is either invert if the browser supports it, or currentColor otherwise.

Is this all?
—It depends. If you want military grade CSS cascade defense, then no, otherwise hold on. Thing is that according to the spec, all: initial doesn't apply initial values to unicode-bidi and direction.

I've never heard of unicode-bidi.
—To be honest, me neither. It is quite complicated and I don't know why one would need it. But as long as this property is not inherited it's safe to leave it untouched.

What's up with direction?
—Good question. Firstly, direction deals with the ltr/rtl problem. Secondly, it is inheritable, so it will definitely affect your components. It can have a negative impact on your components' isolation, so it also doesn't make sense to allow your components to inherit direction from the outside world. Your components should be optimised for ltr anyway, and direction: rtl wont make 'em automatically look good in arabic or hebrew. To fix ltr/rtl problem properly you would need a solution like rtlcss, because you not only want to change direction, but you want to adjust text-align, margin, padding, border-width, etc.

Is this all?
—yes, thanks for your attention.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].