Skip to content

Commit 9a8583f

Browse files
first commit
0 parents  commit 9a8583f

File tree

8 files changed

+8640
-0
lines changed

8 files changed

+8640
-0
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.next
2+
node_modules
3+
/demo/out
4+
coverage/

LICENSE

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
MIT License
2+
3+
Copyright (c) 2021 Fave Asia Technologies Sdn.Bhd
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6+
7+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8+
9+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Fave Tailwind Presets
2+
3+
Fave Tailwind Presets provides a set of preset css styling inlcuding primary color that default uses by Fave.
4+
5+
## Presets
6+
7+
- Font Family - ```inter```
8+
- Primary Color - ```primary-pink ```
9+
- Theme Color
10+
- ```white ```
11+
- ```slate-100,700```
12+
- ```neutral-100,300,400,500,700```
13+
- ```yellow-400```
14+
- ```green-400```
15+
- BoxShadow ```BoxShadow-sm,md,lg,xl,2xl,inner```
16+
- Element Class ```.h1,.h2.h3,.body,.caption,.title```
17+
18+
## Installation
19+
20+
Fave-Preset requires tailwinds css to run.
21+
22+
Install the dependencies and devDependencies and start connect the presets package.
23+
24+
```sh
25+
cd Your Project
26+
```
27+
28+
Install Package
29+
30+
```sh
31+
npm install --Fave-Preset
32+
```
33+
or
34+
```sh
35+
yarn install --Fave-Preset
36+
```
37+
38+
Open ```Tailwind.Config.Js``` in your project root and include the package into your config.
39+
40+
```sh
41+
presets: [
42+
require('./fave-preset'),
43+
],
44+
```
45+
46+
Congratulation, your have already include the Fave Preset into your project.

jest/customMatchers.js

+150
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
const prettier = require('prettier')
2+
const { diff } = require('jest-diff')
3+
4+
function format(input) {
5+
return prettier.format(input, {
6+
parser: 'css',
7+
printWidth: 100,
8+
})
9+
}
10+
11+
expect.extend({
12+
// Compare two CSS strings with all whitespace removed
13+
// This is probably naive but it's fast and works well enough.
14+
toMatchCss(received, argument) {
15+
function stripped(str) {
16+
return str.replace(/\s/g, '').replace(/;/g, '')
17+
}
18+
19+
const options = {
20+
comment: 'stripped(received) === stripped(argument)',
21+
isNot: this.isNot,
22+
promise: this.promise,
23+
}
24+
25+
const pass = stripped(received) === stripped(argument)
26+
27+
const message = pass
28+
? () => {
29+
return (
30+
this.utils.matcherHint('toMatchCss', undefined, undefined, options) +
31+
'\n\n' +
32+
`Expected: not ${this.utils.printExpected(format(received))}\n` +
33+
`Received: ${this.utils.printReceived(format(argument))}`
34+
)
35+
}
36+
: () => {
37+
const actual = format(received)
38+
const expected = format(argument)
39+
40+
const diffString = diff(expected, actual, {
41+
expand: this.expand,
42+
})
43+
44+
return (
45+
this.utils.matcherHint('toMatchCss', undefined, undefined, options) +
46+
'\n\n' +
47+
(diffString && diffString.includes('- Expect')
48+
? `Difference:\n\n${diffString}`
49+
: `Expected: ${this.utils.printExpected(expected)}\n` +
50+
`Received: ${this.utils.printReceived(actual)}`)
51+
)
52+
}
53+
54+
return { actual: received, message, pass }
55+
},
56+
toIncludeCss(received, argument) {
57+
function stripped(str) {
58+
return str.replace(/\s/g, '').replace(/;/g, '')
59+
}
60+
61+
const options = {
62+
comment: 'stripped(received).includes(stripped(argument))',
63+
isNot: this.isNot,
64+
promise: this.promise,
65+
}
66+
67+
const pass = stripped(received).includes(stripped(argument))
68+
69+
const message = pass
70+
? () => {
71+
return (
72+
this.utils.matcherHint('toIncludeCss', undefined, undefined, options) +
73+
'\n\n' +
74+
`Expected: not ${this.utils.printExpected(format(received))}\n` +
75+
`Received: ${this.utils.printReceived(format(argument))}`
76+
)
77+
}
78+
: () => {
79+
const actual = format(received)
80+
const expected = format(argument)
81+
82+
const diffString = diff(expected, actual, {
83+
expand: this.expand,
84+
})
85+
86+
return (
87+
this.utils.matcherHint('toIncludeCss', undefined, undefined, options) +
88+
'\n\n' +
89+
(diffString && diffString.includes('- Expect')
90+
? `Difference:\n\n${diffString}`
91+
: `Expected: ${this.utils.printExpected(expected)}\n` +
92+
`Received: ${this.utils.printReceived(actual)}`)
93+
)
94+
}
95+
96+
return { actual: received, message, pass }
97+
},
98+
})
99+
100+
expect.extend({
101+
// Compare two CSS strings with all whitespace removed
102+
// This is probably naive but it's fast and works well enough.
103+
toMatchFormattedCss(received, argument) {
104+
function format(input) {
105+
return prettier.format(input.replace(/\n/g, ''), {
106+
parser: 'css',
107+
printWidth: 100,
108+
})
109+
}
110+
const options = {
111+
comment: 'stripped(received) === stripped(argument)',
112+
isNot: this.isNot,
113+
promise: this.promise,
114+
}
115+
116+
let formattedReceived = format(received)
117+
let formattedArgument = format(argument)
118+
119+
const pass = formattedReceived === formattedArgument
120+
121+
const message = pass
122+
? () => {
123+
return (
124+
this.utils.matcherHint('toMatchCss', undefined, undefined, options) +
125+
'\n\n' +
126+
`Expected: not ${this.utils.printExpected(formattedReceived)}\n` +
127+
`Received: ${this.utils.printReceived(formattedArgument)}`
128+
)
129+
}
130+
: () => {
131+
const actual = formattedReceived
132+
const expected = formattedArgument
133+
134+
const diffString = diff(expected, actual, {
135+
expand: this.expand,
136+
})
137+
138+
return (
139+
this.utils.matcherHint('toMatchCss', undefined, undefined, options) +
140+
'\n\n' +
141+
(diffString && diffString.includes('- Expect')
142+
? `Difference:\n\n${diffString}`
143+
: `Expected: ${this.utils.printExpected(expected)}\n` +
144+
`Received: ${this.utils.printReceived(actual)}`)
145+
)
146+
}
147+
148+
return { actual: received, message, pass }
149+
},
150+
})

0 commit comments

Comments
 (0)