Skip to content

Commit 02ae810

Browse files
committed
create button component and default primary style
1 parent 782726e commit 02ae810

File tree

13 files changed

+130
-12
lines changed

13 files changed

+130
-12
lines changed

dist/lite-react-ui.es.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/lite-react-ui.umd.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/style.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/main.jsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React, {useState} from 'react'
22
import ReactDOM from 'react-dom'
33
import components from './buildOrSource';
44

5-
const { TextField, TextArea, Navigation } = components;
5+
const { TextField, TextArea, Navigation, Button } = components;
66

77
const _navLinks = [
88
{
@@ -30,6 +30,18 @@ function App() {
3030
return (
3131
<div className="twr-p-10">
3232
<ul class="twr-space-y-5">
33+
<li className="twr-flex twr-space-x-4">
34+
<p className="">{`<Button> component:`}</p>
35+
<Button loading="true" className="twr-w-auto">
36+
Test
37+
</Button>
38+
<Button className="twr-font-bold">
39+
Sign up now 🏄🏽‍♂️
40+
</Button>
41+
<Button loading="true" disabled={true}>
42+
Test
43+
</Button>
44+
</li>
3345
<li>
3446
<p>{`<Navigation> component:`}</p>
3547
<Navigation onNavLinkClick={() => alert('clicked')} className="twr-sticky twr-top-0 twr-z-20 twr-mb-4" navLinks={_navLinks} />

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"concurrently": "^6.2.0",
3232
"lite-react-ui": "^0.2.0",
3333
"npm-watch": "^0.9.0",
34+
"postcss": "^8.3.5",
3435
"react": "^17.0.0",
3536
"react-dom": "^17.0.0"
3637
},

src/assets/styles/buttons.css

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
.twr-button {
2+
@apply twr-relative
3+
twr-flex
4+
twr-py-4
5+
twr-px-8
6+
twr-rounded-lg
7+
twr-transition
8+
twr-outline-none
9+
twr-text-center;
10+
&__primary {
11+
@apply twr-outline-none;
12+
box-shadow: 0px 0px 9px rgba(0, 0, 0, 0.1);
13+
background: #FFFFFF;
14+
&:hover:enabled {
15+
@apply twr-outline-none;
16+
background: #ECECEC;
17+
box-shadow: 0px 0px 19px 2px rgba(0, 0, 0, 0.04);
18+
}
19+
&:focus:enabled {
20+
@apply twr-outline-none twr-border-2;
21+
/* offset 2px sides from increasing border-width of 0px to 2px */
22+
padding: calc(1rem - 2px) calc(2rem - 2px) calc(1rem - 2px) calc(2rem - 2px);
23+
background: #ECECEC;
24+
border-color: rgba(179, 179, 179, 0.26);
25+
box-shadow: 0px 0px 9px rgba(0, 0, 0, 0.1);
26+
}
27+
&:active:enabled {
28+
background: #FCFCFC;
29+
border-color: rgba(178, 178, 178, 0.26);
30+
box-shadow: none;
31+
}
32+
&:disabled {
33+
@apply twr-cursor-not-allowed twr-opacity-50;
34+
box-shadow: 0px 0px 9px rgba(0, 0, 0, 0.1);
35+
}
36+
}
37+
}

src/assets/styles/loading.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.twr-loading {
2+
3+
}

src/assets/svgs/loading.svg

Lines changed: 4 additions & 0 deletions
Loading

src/components/Button.jsx

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import React from 'react'
2+
import ReactDOM from 'react-dom'
3+
import Loading from './Loading';
4+
5+
export default function Button({
6+
id = '',
7+
className = '',
8+
inputClassName = '',
9+
type = '',
10+
text = '',
11+
children = '',
12+
buttonType = 'primary',
13+
loading = false,
14+
loadingText = 'Loading...',
15+
...otherProps
16+
}) {
17+
return (
18+
<button
19+
id={id}
20+
className={`twr-button twr-button__${buttonType} ${className}`}
21+
inputClassName={inputClassName}
22+
type={type}
23+
{...otherProps}
24+
>
25+
<div className="twr-mx-auto">
26+
{
27+
loading ?
28+
(<div className="twr-flex twr-items-center twr-space-x-2 twr-mx-auto">
29+
<div className="flex twr-w-5 twr-h-5">
30+
<Loading />
31+
</div>
32+
<p>
33+
{loadingText}
34+
</p>
35+
</div>) :
36+
children || text
37+
}
38+
</div>
39+
</button>
40+
)
41+
}

src/components/Loading.jsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import React from 'react'
2+
import ReactDOM from 'react-dom'
3+
4+
export default function Loading() {
5+
return (
6+
<svg className="twr-animate-spin twr-w-full twr-h-full" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
7+
<circle className="twr-opacity-10" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
8+
<path className="twr-opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
9+
</svg>
10+
);
11+
}

0 commit comments

Comments
 (0)