-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: remove some unuse js code and fix can not use styles-jsx
- Loading branch information
Chau Duong
committed
Apr 9, 2019
1 parent
186e000
commit 0a331b5
Showing
12 changed files
with
278 additions
and
1,003 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,129 +1,54 @@ | ||
import React, { useState } from 'react'; | ||
import React from 'react'; | ||
import Link from 'next/link'; | ||
|
||
import { connect } from 'react-redux'; | ||
import { testRedux } from '@app/redux/test/actions'; | ||
import { getTest } from '@app/redux/test/selectors'; | ||
|
||
import { Button, Alert, Dropdown, Spinner } from '@app/components/Common'; | ||
|
||
const { DropdownTrigger, DropdownContent } = Dropdown; | ||
const links = [ | ||
{ href: 'https://github.com/segmentio/create-next-app', label: 'Github' }, | ||
].map((link) => { | ||
link.key = `nav-link-${link.href}-${link.label}`; | ||
return link; | ||
}); | ||
|
||
const Nav = (props) => { | ||
const [state, setState] = useState({ | ||
isBusy: false, | ||
count: 0, | ||
}); | ||
return ( | ||
<> | ||
<nav> | ||
<ul> | ||
<li> | ||
<Link prefetch href="/"> | ||
<a onClick={() => props.testRedux(Math.random())}>test redux</a> | ||
const Nav = () => ( | ||
<nav> | ||
<ul> | ||
<li> | ||
<Link prefetch href="/"> | ||
<a>Home</a> | ||
</Link> | ||
</li> | ||
<ul> | ||
{links.map(({ key, href, label }) => ( | ||
<li key={key}> | ||
<Link href={href}> | ||
<a>{label}</a> | ||
</Link> | ||
</li> | ||
<li> | ||
{props.test} | ||
</li> | ||
</ul> | ||
<Button | ||
color="primary" | ||
rounded | ||
onClick={() => | ||
setState({ | ||
isBusy: true, | ||
count: state.count + 1, | ||
})} | ||
isBusy={state.isBusy} | ||
> | ||
{state.count} count | ||
</Button> | ||
|
||
<Alert color="primary" solid> | ||
<strong>Waring! </strong> | ||
<span>Something seriously bad happened.</span> | ||
</Alert> | ||
|
||
<Dropdown> | ||
<DropdownTrigger color="primary"> | ||
bottom | ||
</DropdownTrigger> | ||
<DropdownContent> | ||
<div> | ||
<Link href="/about"> | ||
<a>test redux</a> | ||
</Link> | ||
<div>2222</div> | ||
<div>3333</div> | ||
<div>4444</div> | ||
<div>5555</div> | ||
</div> | ||
</DropdownContent> | ||
</Dropdown> | ||
<br /> | ||
<Dropdown direction="top"> | ||
<DropdownTrigger color="primary"> | ||
top | ||
</DropdownTrigger> | ||
<DropdownContent> | ||
<div> | ||
<Link href="/about"> | ||
<a>test redux</a> | ||
</Link> | ||
<div>2222</div> | ||
<div>3333</div> | ||
<div>4444</div> | ||
<div>5555</div> | ||
</div> | ||
</DropdownContent> | ||
</Dropdown> | ||
<br /> | ||
<Dropdown direction="left"> | ||
<DropdownTrigger color="primary"> | ||
left | ||
</DropdownTrigger> | ||
<DropdownContent> | ||
<div> | ||
<Link href="/about"> | ||
<a>test redux</a> | ||
</Link> | ||
<div>2222</div> | ||
<div>3333</div> | ||
<div>4444</div> | ||
<div>5555</div> | ||
</div> | ||
</DropdownContent> | ||
</Dropdown> | ||
<br/> | ||
<Dropdown direction="right"> | ||
<DropdownTrigger color="primary"> | ||
right | ||
</DropdownTrigger> | ||
<DropdownContent> | ||
<div> | ||
<Link href="/about"> | ||
<a>test redux</a> | ||
</Link> | ||
<div>2222</div> | ||
<div>3333</div> | ||
<div>4444</div> | ||
<div>5555</div> | ||
</div> | ||
</DropdownContent> | ||
</Dropdown> | ||
<Spinner /> | ||
</nav> | ||
</> | ||
); | ||
}; | ||
|
||
const mapStateToProps = state => ({ | ||
test: getTest(state), | ||
}); | ||
|
||
const mapDispatchToProps = { | ||
testRedux, | ||
}; | ||
|
||
export default connect(mapStateToProps, mapDispatchToProps)(Nav); | ||
))} | ||
</ul> | ||
</ul> | ||
|
||
<style jsx>{` | ||
nav { | ||
text-align: center; | ||
} | ||
ul { | ||
display: flex; | ||
justify-content: space-between; | ||
} | ||
nav > ul { | ||
padding: 4px 16px; | ||
} | ||
li { | ||
display: flex; | ||
padding: 6px 8px; | ||
} | ||
a { | ||
color: #067df7; | ||
text-decoration: none; | ||
font-size: 13px; | ||
} | ||
`}</style> | ||
</nav> | ||
); | ||
|
||
export default Nav; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import React from 'react'; | ||
import css from 'styled-jsx/css'; | ||
import Link from 'next/link'; | ||
|
||
import { Button, Alert, Dropdown, Spinner } from '@app/components/Common'; | ||
const { DropdownTrigger, DropdownContent } = Dropdown; | ||
|
||
const style = css` | ||
.content { | ||
padding: 2rem; | ||
} | ||
.content .wrap { | ||
display: flex; | ||
justify-content: space-around; | ||
} | ||
.content .component { | ||
font-weight: bold; | ||
color: black; | ||
flex-direction: column; | ||
display: flex; | ||
} | ||
:global(.primary), | ||
:global(.btn-primary) { | ||
background-color: blue; | ||
color: white; | ||
} | ||
:global(.warning) { | ||
background-color: yellow; | ||
color: black; | ||
} | ||
`; | ||
|
||
const Home = () => ( | ||
<div className="content"> | ||
<style jsx>{style}</style> | ||
<Link href="/"><a>Back</a></Link> | ||
<div className="wrap"> | ||
<div className="component"> | ||
DropDown | ||
<Dropdown> | ||
<DropdownTrigger color="primary"> | ||
For bottom | ||
</DropdownTrigger> | ||
<DropdownContent> | ||
<div> | ||
<Link href="/about"> | ||
<a>test 1</a> | ||
</Link> | ||
<div>2222</div> | ||
<div>3333</div> | ||
<div>4444</div> | ||
<div>5555</div> | ||
</div> | ||
</DropdownContent> | ||
</Dropdown> | ||
</div> | ||
<div className="component"> | ||
Alert | ||
<Alert color="warning" solid> | ||
<strong>Waring! </strong> | ||
<span>Something seriously bad happened.</span> | ||
</Alert> | ||
<Alert color="primary" solid> | ||
<strong>Opps! </strong> | ||
<span>Hi</span> | ||
</Alert> | ||
</div> | ||
<div className="component"> | ||
Button | ||
<Button | ||
color="primary" | ||
rounded | ||
> | ||
Primary | ||
</Button> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
|
||
export default Home; |
Oops, something went wrong.