Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
00c84f8
commit fea984f
Showing
12 changed files
with
247 additions
and
118 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import styled from 'styled-components'; | ||
import { NavLink } from 'react-router-dom'; | ||
import logo from '../logo.png'; | ||
import { NavMenus } from './NavMenus'; | ||
|
||
export const Warpper = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
`; | ||
|
||
const HeaderWarpper = styled.div` | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: center; | ||
height: 42px; | ||
padding-left: 10px; | ||
padding-right: 10px; | ||
border-bottom: 1px solid var(--color-border-default); | ||
position: sticky; | ||
top: 0; | ||
z-index: 9999; | ||
background-color: var(--color-canvas-subtle); | ||
`; | ||
|
||
const Title = styled(NavLink)` | ||
font-size: 14px; | ||
font-weight: bold; | ||
display: flex; | ||
align-items: center; | ||
gap: 10px; | ||
text-decoration: none; | ||
color: var(--color-fg-muted); | ||
> img { | ||
height: 21px; | ||
} | ||
`; | ||
|
||
export const Header = () => { | ||
return ( | ||
<HeaderWarpper> | ||
<Title to="/"> | ||
<img src={logo} alt="Logo" /> | ||
<span>CodeMirror Theme</span> | ||
</Title> | ||
<NavMenus /> | ||
</HeaderWarpper> | ||
); | ||
}; |
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,48 @@ | ||
import styled, { css } from 'styled-components'; | ||
import { NavLink } from 'react-router-dom'; | ||
|
||
export const Tools = styled.div` | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
gap: 2px; | ||
& a { | ||
display: flex; | ||
align-items: center; | ||
} | ||
`; | ||
|
||
const style = css` | ||
padding: 2px 5px; | ||
border-radius: 3px; | ||
text-decoration: none; | ||
color: var(--color-accent-emphasis); | ||
&.active { | ||
background-color: var(--color-neutral-muted); | ||
color: var(--color-fg-default); | ||
} | ||
`; | ||
|
||
export const Link = styled(NavLink)` | ||
${style} | ||
`; | ||
|
||
export const Hyperlink = styled.a` | ||
${style} | ||
`; | ||
|
||
export const NavMenus = () => { | ||
return ( | ||
<Tools> | ||
<Link to="/">Home</Link> | ||
<Link to="/extensions">Extensions</Link> | ||
<Link to="/theme/">Themes</Link> | ||
<Link to="/editor/theme">Themes Editor</Link> | ||
<Link to="/theme/doc">Theme Doc</Link> | ||
<Hyperlink href="https://github.com/uiwjs/react-codemirror" target="__blank"> | ||
Github | ||
</Hyperlink> | ||
<dark-mode permanent /> | ||
</Tools> | ||
); | ||
}; |
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
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,91 @@ | ||
import { Fragment } from 'react'; | ||
import styled from 'styled-components'; | ||
import { Link } from 'react-router-dom'; | ||
import CodeMirror from '@uiw/react-codemirror'; | ||
import { color } from '@uiw/codemirror-extensions-color'; | ||
import { langs } from '@uiw/codemirror-extensions-langs'; | ||
import { SiderMenus } from '../themes/SiderMenus'; | ||
import { Warpper } from '../../../components/Warpper'; | ||
import { themeData } from '../themes/Datas'; | ||
import { toSnakeCase } from '../themes/Document'; | ||
|
||
export const toTitleCase = (str: string = '') => | ||
str | ||
.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g) | ||
?.map((x) => x.charAt(0).toUpperCase() + x.slice(1)) | ||
.join(' '); | ||
|
||
const ThemesWarpper = styled.div` | ||
grid-template-columns: repeat(3, minmax(0, 1fr)); | ||
gap: 2.5rem; | ||
display: grid; | ||
padding: 2.6rem; | ||
a { | ||
text-decoration: none; | ||
} | ||
@media (max-width: 1280px) { | ||
grid-template-columns: repeat(3, minmax(0, 1fr)); | ||
} | ||
@media (max-width: 1024px) { | ||
grid-template-columns: repeat(2, minmax(0, 1fr)); | ||
} | ||
@media (max-width: 860px) { | ||
grid-template-columns: repeat(1, minmax(0, 1fr)); | ||
} | ||
`; | ||
|
||
const ThemeCard = styled.div` | ||
padding: 1rem; | ||
box-shadow: 0 0 #0000, 0 0 #0000, 0 0 #0000, 0 1px 2px 0 rgba(0, 0, 0, 0.05); | ||
border-radius: 0.5rem; | ||
border: 1px solid var(--color-neutral-muted); | ||
background-color: var(--color-canvas-subtle); | ||
transition-property: all; | ||
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); | ||
transition-duration: 0.2s; | ||
&:hover { | ||
transform: translate(0, -0.25rem) rotate(0) skewX(0) skewY(0) scaleX(1) scaleY(1); | ||
} | ||
`; | ||
|
||
const Title = styled.div` | ||
font-weight: 600; | ||
padding-bottom: 0.68rem; | ||
`; | ||
|
||
const codeString = `import React, {useState} from 'react'; | ||
// My favorite component | ||
const Counter = () => { | ||
const [value, setValue] = useState(0); | ||
return <span>{value}</span>; | ||
};`; | ||
|
||
export function ThemesHome() { | ||
return ( | ||
<Fragment> | ||
<SiderMenus /> | ||
<Warpper> | ||
<ThemesWarpper> | ||
{Object.keys(themeData).map((name, idx) => { | ||
const [_name, _theme] = toSnakeCase(name) || []; | ||
return ( | ||
<Link key={idx} to={`/theme/data/${_name}${_theme ? `/${_theme}` : ''}`}> | ||
<ThemeCard> | ||
<Title>{toTitleCase(name)}</Title> | ||
<CodeMirror | ||
value={codeString} | ||
height="165px" | ||
theme={themeData[name as keyof typeof themeData]} | ||
extensions={[color, langs.jsx()]} | ||
/> | ||
</ThemeCard> | ||
</Link> | ||
); | ||
})} | ||
</ThemesWarpper> | ||
</Warpper> | ||
</Fragment> | ||
); | ||
} |
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
Oops, something went wrong.