Skip to content

Add component Button #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"name": "rstrtt",
"version": "0.10.0",
"description": "Dead simple CSS framework.",
"main": "dist/rstrtt.css",
"scripts": {
"start": "parcel src/index.html --open",
"test": "react-scripts test"
Expand All @@ -23,8 +22,8 @@
"dependencies": {
"color-preset": "^1.0.1",
"cssnano": "^5.0.2",
"parcel": "^2.0.0-beta.2",
"postcss": "^8.2.13",
"parcel": "^2.0.0-nightly.952",
"postcss": "^8.4.5",
"postcss-cssnext": "^3.1.0",
"postcss-import": "^14.0.1",
"postcss-mixins": "^7.0.3",
Expand All @@ -33,6 +32,7 @@
"react-dom": "^17.0.2"
},
"devDependencies": {
"@babel/core": "^7.16.5",
"@babel/preset-env": "^7.14.0",
"@babel/preset-react": "^7.13.13",
"@testing-library/jest-dom": "^5.11.4",
Expand All @@ -49,6 +49,7 @@
"eslint-plugin-promise": "^5.1.0",
"eslint-plugin-react": "^7.24.0",
"react-scripts": "^4.0.3",
"standard": "^16.0.3"
"standard": "^16.0.3",
"typescript": "^4.5.4"
}
}
27 changes: 27 additions & 0 deletions src/components/button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
'use strict'

import * as React from 'react'
import '../css/rstrtt.css'

const classNames = {
primary: 'btn btn-primary',
success: 'btn btn-success',
info: 'btn btn-info',
warning: 'btn btn-warning',
error: 'btn btn-error',
block: 'btn btn-primary btn-block',
'btn-ghost': 'btn btn-default btn-ghost',
'primary-ghost': 'btn btn-primary btn-ghost',
'success-ghost': 'btn btn-success btn-ghost',
'info-ghost': 'btn btn-info btn-ghost',
'warning-ghost': 'btn btn-warning btn-ghost',
'error-ghost': 'btn btn-error btn-ghost',
default: 'btn btn-defaul'
}

const Button = (props: { type: string; value: string; onClick: any }) => {
const { type, value, onClick } = props
return <div className={classNames[type]} onClick={onClick}>{value}</div>
}

export default Button
3 changes: 2 additions & 1 deletion src/components/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import ProgressBar from './progress-bar'
import List from './list'
import BlockQuote from './block-quote'
import Button from './button'

export { ProgressBar, List, BlockQuote }
export { ProgressBar, List, BlockQuote, Button }
2 changes: 1 addition & 1 deletion src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
</head>
<body class="rstrtt">
<div id="app"></div>
<script src="index.tsx"></script>
<script src="index.tsx" type=module></script>
</body>
</html>
40 changes: 38 additions & 2 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import * as React from 'react'
import { useState } from 'react'
import * as ReactDOM from 'react-dom'
import { ProgressBar, List } from './components'
import { ProgressBar, List, Button } from './components'

const ProgressBarSample = () => {
let [percent, setPercent] = useState(0)
Expand Down Expand Up @@ -53,10 +53,46 @@ const ProgressBarSampleError = () => {

const mountNode = document.getElementById('app')
ReactDOM.render(
<div>
<div className="container">
<ProgressBarSample /><br />
<ProgressBarSampleWithPercents /><br />
<ProgressBarSampleSuccess /><br />
<ProgressBarSampleError /><br />
<List data={[{ value: 'shadock language', next: ['ga', 'bu', 'zo', 'meu'] }, 'one', 'two', 'three']} />
<br />
<h2> Buttons</h2>
<p>
{/* <Button /> */}
<Button type="primary"value="primary" onClick={() => { console.log('clicked') }}/>
<Button type="success"value="success" onClick={() => { console.log('clicked') }}/>
<Button type="info"value="info" onClick={() => { console.log('clicked') }}/>
<Button type="warning"value="warning" onClick={() => { console.log('clicked') }}/>
<Button type="error"value="error" onClick={() => { console.log('clicked') }}/>
</p>
<p>
<Button type="btn-ghost" value="btn-ghost" onClick={() => { console.log('clicked') }}/>
<Button type="primary-ghost" value="primary-ghost" onClick={() => { console.log('clicked') }}/>
<Button type="success-ghost" value="success-ghost" onClick={() => { console.log('clicked') }}/>
<Button type="info-ghost" value="info-ghost" onClick={() => { console.log('clicked') }}/>
<Button type="warning-ghost" value="warning-ghost" onClick={() => { console.log('clicked') }}/>
<Button type="error-ghost" value="error-ghost" onClick={() => { console.log('clicked') }}/>
</p>
<p>
<Button type="block" value="block" onClick={() => { console.log('clicked') }}/>
</p>
{/* TODO: add code */}
{/* <pre>
<code className="lang-html">
&lt;button className=&quot;btn btn-default&quot;/&gt;
&lt;button className=&quot;btn btn-primary&quot;/&gt;
&lt;button className=&quot;btn btn-success&quot;/&gt;
&lt;button className=&quot;btn btn-info&quot;/&gt;
&lt;button className=&quot;btn btn-warning&quot;/&gt;
&lt;button className=&quot;btn btn-error&quot;/&gt;

&lt;button className=&quot;btn btn-primary btn-ghost&quot;&gt;Ghost Button/&gt;

&lt;button className=&quot;btn btn-primary btn-block&quot;&gt;Block Level Button/&gt;
</code>
</pre> */}
</div>, mountNode)
Loading