0.1.53 • Published 3 years ago

shortstyle v0.1.53

Weekly downloads
278
License
MIT
Repository
github
Last release
3 years ago

Shortstyle

CSS written in .(s)css file:

padding-top: 10px;
padding-bottom: 20px;
padding-right: 5px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: flex-end;

"helper classes" from Fancy-pancy-css-lib-XYZ (or your own custom helpers):

className="pt10 pb20 pr5 flex-column justify-content-middle alien-items-end"

Shortstyle:

s="p10_5_20_0 xcce"

Shortstyle lets you style in the most susynced way you've ever tried.

It comes with the most common functions: h, w, p, m, ... But you can also define your own functions: sh, q, ...

How it works:

Think of each work in the shortstyle string as a call to a styling function.

"h10" is a call to the function h like so h(10) and h is just height so it's very simple:h = (x) => {height: `${x}px`}

"posa" is a call to pos(a):

const pos = (x) => {
   switch (x) {
      case 'a': return {position: 'absolute'};
      case 'f': return {position: 'fixed'};
      case 'r': return {position: 'relative'};
      case 's': return {position: 'static'};
      default: throw new Error(`pos doesn't support ${x}`);
   }
};

API DOCS

Note that you can customize the unit

stylestring-basedgenerated css
height'h14'height: 14
width'w14'width: 14
min-height'ih5'min-height: 5
min-width'iw7'min-width: 7
max-height'xh20'max-height: 20
max-width'xw34'max-width: 34
position'posa'position: absolute
.'posf'position: fixed
.'posr'position: relative
.'poss'position: static
left'lef10'left: 10
right'rig10'right: 10
top'top'top: 10
bottom'bot'bottom: 10
margin'm10_4_2_8'margin: 10 4 2 8
.'m10_5'margin: 10 5
.'mt10'margin-top: 10
.'mb10'margin-bottom: 10
.'ml10'margin-left: 10
.'mr10'margin-right: 10
padding'p10_4_2_8'padding: 10 4 2 8
.'p10_5'padding: 10 5
.'pt10'padding-top: 10
.'pb10'padding-bottom: 10
.'pl10'padding-left: 10
.'pr10'padding-right: 10
z-index'z99'z-index: 99
text-align'tac'text-align: center
.'tal'text-align: left
.'tar'text-align: right
white-space'whn'white-space: nowrap
.'whp'white-space: pre
.'whi'white-space: initial
overflow'ova'overflow: auto
.'ovs'overflow: scroll
.'ovh'overflow: hidden
.'ovv'overflow: visible
.'ovi'overflow: initial
text-overflow'ove'text-overflow: ellipsis
.'ovs'text-overflow: scroll
.'ovh'text-overflow: hidden
.'ovv'text-overflow: visible
.'ovi'text-overflow: initial

Flexbox

Flex is done by 1-7 character each representing a flex property

# Property based    /    String based
x: 'ccew10'                'xccew10'

   flex-direction (r = row, c = column)
   |  justify-content (c = center, e = flex-end, s = flex-start, a = space-around, b = space-between)
   |  |  align-items (c = center, e = flex-end, s = flex-start, b = baseline, t = stretch)
   |  |  |  flex-wrap (w = wrap, r = wrap-reverse)
   |  |  |  |  flex-grow (unit)
   |  |  |  |  |  flex-shrink (unit)
   |  |  |  |  |  |
   v  v  v  v  v  v
x  c  c  e  w  1  0

# Examples:
xccew10 => display: flex; flex-direction: column; justify-content: center; align-items: flex-end; flex-wrap: wrap; flex-grow: 1; flex-shrink: 0;
xcc => display: flex; flex-direction: column; justify-content: center;
x__cr => display: flex; align-items: center; flex-wrap: wrap-reverse;

Overridables

Some of the style functions are intended for you to override to get the application-specific behaviour you want.

Font

A font function can typically give the following behaviour

   font-family (eg. t = Times New Roman, a = Arial, ...)
   |  font-size (number unit)
   |  |  color (eg. bk = black, re = red, bu = blue, ...)
   |  |  |  font-weight (eg. number unit * 100)
   |  |  |  |
   |  |  |  |
   |  |  |  |
   v  v  v  v
f  t  5  bu 7

# Examples:
ft5bu7 => font-family: Times; font-size: 1.125rem; color: blue; font-weight: 700;
fa5__2 => font-family: Arial; font-size: 1.125rem; font-weight: 200;
f_9___ => font-size: 1.6rem;

Questions?

Does this affect performance? Not much in most cases thanks to optimizations.

0.1.53

3 years ago

0.1.52

3 years ago

0.1.50

3 years ago

0.1.51

3 years ago

0.1.49

3 years ago

0.1.47

3 years ago

0.1.48

3 years ago

0.1.44

3 years ago

0.1.45

3 years ago

0.1.46

3 years ago

0.1.43

3 years ago

0.1.42

3 years ago

0.1.41

3 years ago

0.1.40

3 years ago

0.1.39

3 years ago

0.1.37

3 years ago

0.1.38

3 years ago

0.1.36

3 years ago

0.1.35

3 years ago

0.1.34

4 years ago

0.1.33

4 years ago

0.1.32

4 years ago

0.1.30

4 years ago

0.1.31

4 years ago

0.1.29

4 years ago

0.1.28

5 years ago

0.1.27

6 years ago

0.1.26

6 years ago

0.1.25

6 years ago

0.1.24

6 years ago

0.1.23

6 years ago

0.1.22

6 years ago

0.1.21

6 years ago

0.1.20

6 years ago

0.1.19

6 years ago

0.1.18

6 years ago

0.1.17

6 years ago

0.1.16

6 years ago

0.1.15

6 years ago

0.1.14

6 years ago

0.1.13

6 years ago

0.1.12

6 years ago

0.1.11

6 years ago

0.1.10

6 years ago

0.1.9

6 years ago

0.1.8

6 years ago

0.1.7

6 years ago

0.1.6

6 years ago

0.1.5

7 years ago

0.1.4

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago