@iyio/at-dot-css 0.5.13 → 0.5.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +174 -0
  2. package/package.json +2 -2
package/README.md ADDED
@@ -0,0 +1,174 @@
1
+ # at-dot-css
2
+ A fast and lightweight css-in-js library. The at-dot-css is a superset of css with a few simple
3
+ additions to make it a little easier to scope component styles, work with variables and define
4
+ responsive breakpoints.
5
+
6
+ The syntax is designed to be vary simple to implement, only requiring a simple find and
7
+ replace algorithm which keeps parsing times to a minimum. There is no nesting, functions or mixins,
8
+ just good old css with a couple of extra goodies 🤓
9
+
10
+ ## Usage
11
+ AtDot styles are defined using the `atDotCss` function. The `atDotCss` function returns a ParseAtDotStyle
12
+ object with functions that correspond to each of the `@.` selectors defined in the style. After the
13
+ first call to a selector function the style is parsed and a new style sheet is inserted into the
14
+ head of the document or added to a custom style sheet renderer.
15
+
16
+
17
+ ![at-dot-css example](https://raw.githubusercontent.com/iyioio/common/main/assets/at-dot-css/at-dot-example.png)
18
+ *(note - css-in-js syntax highlighting is provided by the `high-js` vscode extension)*
19
+
20
+ The css in the example above is converted to the css below.
21
+ ``` css
22
+ .Example{
23
+ display:flex;
24
+ flex-direction:row;
25
+ align-items:center;
26
+ padding:1rem;
27
+ border-radius:12px;
28
+ border:1px solid var(--Example-color);
29
+ gap:1rem;
30
+ }
31
+
32
+ .Example-header{
33
+ margin:0;
34
+ }
35
+
36
+ .Example-button{
37
+ border:none;
38
+ background-color:#ccc;
39
+ padding:1rem;
40
+ border-radius:12px;
41
+ }
42
+ .Example-button.active{
43
+ background-color:var(--Example-color);
44
+ }
45
+
46
+ @media(max-width:768px){
47
+ .Example{
48
+ flex-direction:column;
49
+ align-items:flex-start;
50
+ }
51
+ }
52
+ ```
53
+
54
+
55
+ ## Using with NextJs
56
+ When using at-dot-css in a NextJS project and rending server side or at build time styles are added
57
+ to a style queue that is then rendered using the `NextJsStyleSheets` component from the
58
+ `@iyio/nextjs-common` package. Using the `NextJsStyleSheets` component allows css generated by
59
+ at-dot-css to be included in the css bundles generated by NextJs.
60
+
61
+ ## Installation
62
+ ``` sh
63
+ npm install @iyio/at-dot-css
64
+ ```
65
+
66
+ ## Configuration
67
+ There is no configuration 🥹, no extra build steps, no messing with webpack. Just install the package
68
+ and start using it 🥳
69
+
70
+ ## The Syntax
71
+ All the code examples below assume the name of the current style is "Example".
72
+
73
+ ### Root Selector
74
+ `@.root` - The root selector is replaced with the current style name.
75
+
76
+ ``` css
77
+ /* at-dot */
78
+ @.root{
79
+ padding:1rem;
80
+ }
81
+
82
+ /* converted css*/
83
+ .Example{
84
+ padding:1rem;
85
+ }
86
+ ```
87
+
88
+
89
+ ### Named Selector
90
+ `@.{selector-name}` - Named selectors are prefixed with the name of the current style.
91
+
92
+ ``` css
93
+ /* at-dot */
94
+ @.title{
95
+ margin:1rem 0;
96
+ }
97
+
98
+ /* converted css*/
99
+ .Example-title{
100
+ margin:1rem 0;
101
+ }
102
+ ```
103
+
104
+ ### Variables
105
+ `@@{variable-name}` - Variable names are prefixed with the current style name and wrapped in a var function call.
106
+
107
+ ``` css
108
+ /* at-dot */
109
+ .some-name{
110
+ color:@@color;
111
+ width:calc( 100% - @@extraMargin )
112
+ }
113
+
114
+ /* converted css*/
115
+ .some-name{
116
+ color:var(--Example-color);
117
+ width:calc( 100% - var(--Example-extraMargin) )
118
+ }
119
+ ```
120
+ *(note - when using vars in calculations a space after the var name is required for typescript intellisense to function correctly)*
121
+
122
+ ### Breakpoint Media Queries
123
+ `@{break-point}` - Breakpoint media queries allow you to quickly define media queries for standard
124
+ breakpoints.
125
+
126
+ ``` css
127
+ /* at-dot */
128
+ @tabletSmDown{
129
+ .my-component{
130
+ flex-direction:column;
131
+ }
132
+ }
133
+ @tabletSmUp{
134
+ .my-title{
135
+ font-size:2rem;
136
+ }
137
+ }
138
+
139
+ /* converted css*/
140
+ @media(max-width:768px){
141
+ .my-component{
142
+ flex-direction:column;
143
+ }
144
+ }
145
+ @media(min-width:577px){
146
+ .my-title{
147
+ font-size:2rem;
148
+ }
149
+ }
150
+ ```
151
+
152
+ Breakpoints:
153
+ - `@mobileSmUp` - Small mobile breakpoint and up - (all breakpoints)
154
+ - `@mobileUp` - Mobile breakpoint and up
155
+ - `@tabletSmUp` - Small tablet breakpoint and up
156
+ - `@tabletUp` - Tablet breakpoint and up
157
+ - `@desktopSmUp` - Small desktop breakpoint and up
158
+ - `@desktopUp` - Desktop breakpoint and up
159
+ - `@mobileSmDown` - Small mobile breakpoint and down
160
+ - `@mobileDown` - Mobile breakpoint and down
161
+ - `@tabletSmDown` - Small tablet breakpoint and down
162
+ - `@tabletDown` - Tablet breakpoint and down
163
+ - `@desktopSmDown` - Small desktop breakpoint and down
164
+ - `@desktopDown` - Desktop breakpoint and down - (all breakpoints)
165
+
166
+
167
+ ## Syntax Highlighting
168
+ Syntax highlighting is provided using the [high-js](https://marketplace.visualstudio.com/items?itemName=IYIO.high-js) vscode extension
169
+
170
+
171
+ ## Type Safety
172
+ When using at-dot-css with TypeScript you get full type safety and intellisense.
173
+
174
+ ![intellisense](https://raw.githubusercontent.com/iyioio/common/main/assets/at-dot-css/intellisense.png)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iyio/at-dot-css",
3
- "version": "0.5.13",
3
+ "version": "0.5.15",
4
4
  "sideEffects": false,
5
5
  "dependencies": {
6
6
  "date-fns": ">=2.30.0",
@@ -9,7 +9,7 @@
9
9
  "zod": ">=3.22.4"
10
10
  },
11
11
  "peerDependencies": {
12
- "@iyio/common": "^0.5.13"
12
+ "@iyio/common": "^0.5.15"
13
13
  },
14
14
  "main": "./src/index.js",
15
15
  "types": "./src/index.d.ts",