Skip to content

Commit

Permalink
Merge pull request #8 from CSSSR/CORE-29
Browse files Browse the repository at this point in the history
CORE-29
  • Loading branch information
palmflip authored Apr 29, 2019
2 parents 87df1a0 + c8b4957 commit cf9198c
Show file tree
Hide file tree
Showing 33 changed files with 1,004 additions and 966 deletions.
6 changes: 6 additions & 0 deletions examples/nextjs-integration/components/Logo/Logo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const Logo: React.FC<ILogoProps> = props => {
<Link href='/docs'>
<TextLink
fontStyle='font_roboto_slab_light'
theme={{dark: {}}}
css={css`
margin-top: 0;
margin-bottom: 0;
Expand All @@ -26,6 +27,11 @@ const Logo: React.FC<ILogoProps> = props => {
:hover {
color: rgba(0, 0, 0, 0.7);
${({ theme }) => theme.dark && css`
color: white;
background-color: black;
`}
}
`}
{...props}
Expand Down
24 changes: 0 additions & 24 deletions examples/nextjs-integration/components/Pre/Pre.tsx

This file was deleted.

44 changes: 0 additions & 44 deletions examples/nextjs-integration/components/Table/Table.tsx

This file was deleted.

20 changes: 20 additions & 0 deletions examples/nextjs-integration/components/docs/Headings/Headings.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import styled from '@emotion/styled'
import { Heading as OriginHeading } from '@asmy/core-design'

const headingsWithFontStyle = {
H1: props => <OriginHeading.H1 fontStyle="font_h1_slab" {...props} />,
H2: props => <OriginHeading.H2 fontStyle="font_h2_slab" {...props} />,
H3: props => <OriginHeading.H3 fontStyle="font_h3_slab" {...props} />,
H4: props => <OriginHeading.H4 fontStyle="font_h3_slab" {...props} />,
H5: props => <OriginHeading.H5 fontStyle="font_h3_slab" {...props} />,
H6: props => <OriginHeading.H6 fontStyle="font_h3_slab" {...props} />,
}

const H1 = styled(headingsWithFontStyle.H1)`grid-column: 1 / span 12`
const H2 = styled(headingsWithFontStyle.H2)`grid-column: 1 / span 12`
const H3 = styled(headingsWithFontStyle.H3)`grid-column: 1 / span 12`
const H4 = styled(headingsWithFontStyle.H4)`grid-column: 1 / span 12`
const H5 = styled(headingsWithFontStyle.H5)`grid-column: 1 / span 12`
const H6 = styled(headingsWithFontStyle.H6)`grid-column: 1 / span 12`

export { H1, H2, H3, H4, H5, H6 }
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { H1, H2, H3, H4, H5, H6 } from './Headings'
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import styled from '@emotion/styled'
import { Text as OriginText } from '@asmy/core-design'

const Text = props => <OriginText fontStyle="font_p24_strong" {...props} />

const Paragraph = styled(Text)`
margin-top: 20px;
grid-column: 1 / span 12
`

export { Paragraph }
export default Paragraph
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { deafult, Paragraph } from './Paragraph'
14 changes: 14 additions & 0 deletions examples/nextjs-integration/components/docs/Pre/Pre.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import styled from '@emotion/styled'

const OriginPre = styled.pre`
margin: 0;
padding: 40px;
background-color: #f2f2f2;
`

const Pre = styled(OriginPre)`
grid-column: 1 / span 12;
`

export { Pre }
export default Pre
13 changes: 13 additions & 0 deletions examples/nextjs-integration/components/docs/Table/Table.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import styled from '@emotion/styled'

const OriginTable = styled.table`
border: 1px solid black;
border-collapse: collapse;
`

const Table = styled(OriginTable)`
grid-column: 1 / span 12;
`

export { Table }
export default Table
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import styled from '@emotion/styled'

import { font_p24_strong } from '@asmy/core-design'

const TD = styled.td`
padding: 12px;
border: 1px solid black;
text-align: left;
vertical-align: top;
${font_p24_strong}
`
const TH = styled(TD.withComponent('th'))`
vertical-align: middle;
color: white !important;
`

export { TD, TH }
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { TD, TH } from './TableCell'
14 changes: 14 additions & 0 deletions examples/nextjs-integration/components/docs/TableRow/TableRow.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import styled from '@emotion/styled'

const TableRow = styled.tr`
thead & {
background-color: #343434;
}
:nth-of-type(even) {
background-color: #f2f2f2;
}
`

export { TableRow }
export default TableRow
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default, TableRow } from './TableRow'
5 changes: 2 additions & 3 deletions examples/nextjs-integration/next.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const { print } = require('q-i')
const withPlugins = require('next-compose-plugins');
const withFonts = require('next-fonts');
const withMDX = require('@zeit/next-mdx')();

const withTypescript = require('@zeit/next-typescript')
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin')
Expand Down Expand Up @@ -31,6 +32,4 @@ module.exports = withPlugins([[withTypescript, {

return config
},
}], withFonts]);

// module.exports = withTypescript()
}], [withMDX, { pageExtensions: ['tsx', 'mdx'] }], withFonts]);
1 change: 1 addition & 0 deletions examples/nextjs-integration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"react-dom": "^16.8.6"
},
"devDependencies": {
"@zeit/next-mdx": "^1.2.0",
"fork-ts-checker-webpack-plugin": "^1.0.2",
"prettier": "^1.17.0",
"q-i": "^2.0.1",
Expand Down
66 changes: 66 additions & 0 deletions examples/nextjs-integration/pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import React from 'react'
import App, { Container } from 'next/app'

import { H1, H2, H3, H4, H5, H6 } from '../components/docs/Headings'
import { Paragraph } from '../components/docs/Paragraph'
import { Table } from '../components/docs/Table'
import { TableRow } from '../components/docs/TableRow'
import { Pre } from '../components/docs/Pre'
import { TD, TH } from '../components/docs/TableCells'
import { ProjectLayout } from '../components/ProjectLayout'

import { Grid } from '@asmy/core-design'


const components = {
h1: H1,
h2: H2,
h3: H3,
h4: H4,
h5: H5,
h6: H6,
p: Paragraph,
table: Table,
tr: TableRow,
td: TD,
th: TH,
pre: Pre,
wrapper: Grid,
}

class MyApp extends App {
static async getInitialProps({ Component, ctx }) {
let pageProps = {};

if (Component.getInitialProps) {
pageProps = await Component.getInitialProps(ctx);
}

if (ctx.pathname.slice(0, 5) === '/docs') {
pageProps.isDocsPage = true
}

return { pageProps };
}

render() {
const { Component, pageProps } = this.props;

return (
<Container>
{pageProps.isDocsPage
? <ProjectLayout>
<Component
components={components}
{...pageProps}
/>
</ProjectLayout>

: <Component {...pageProps} />
}
</Container>
);
}
}

export default MyApp;
67 changes: 67 additions & 0 deletions examples/nextjs-integration/pages/docs/button.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import { css } from '@emotion/core'
import { Button } from '@asmy/core-design'

# Button

<Button
css={css`grid-column: 1 / span 3;`}
kind="primary"
onClick={() => alert('Ты кликнул кнопку')}
>
Кнопка
</Button>

<Button
css={css`grid-column: 4 / span 3;`}
kind="primary"
onClick={() => alert('Ты кликнул кнопку')}
disabled
>
Кнопка
</Button>

<Button
css={css`grid-column: 7 / span 3;`}
kind="secondary"
onClick={() => alert('Ты кликнул кнопку')}
>
Кнопка
</Button>

<Button
css={css`grid-column: 10 / span 3;`}
kind="secondary"
onClick={() => alert('Ты кликнул кнопку')}
disabled
>
Кнопка
</Button>

Компонент кнопки. Используется как триггер для выполнения определённого действия. Кнопка однозначно сообщает пользователю, что произойдёт после нажатия на неё.

---------------------------------------
## Свойства
Имя | Допустимые значения | Значение по умолчанию | Комментарий
--------- | -------------------- | --------------------- | ----------------
kind | primary \| secondary | primary | Тема кнопки
disabled | true \| false | false | Отвечает за disabled состояние кнопки

---------------------------------------
## Хендлеры
Имя | Аргументы | Комментарий
--------- | --------- | ---------------
onClick | event | Функция, которая будет исполнятся при клике на кнопку

---------------------------------------
## Код
```
import { Button } from '@asmy/core-design'
<Button
kind="secondary"
onClick={handleClick}
disabled
>
Кнопка
</Button>
```
Loading

0 comments on commit cf9198c

Please sign in to comment.