-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Pham Hai Duong
authored
Jul 16, 2020
1 parent
d3df4f4
commit 8a103b6
Showing
21 changed files
with
45,269 additions
and
21 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,14 @@ | ||
'use strict' | ||
|
||
// This is a custom Jest transformer turning style imports into empty objects. | ||
// http://facebook.github.io/jest/docs/en/webpack.html | ||
|
||
module.exports = { | ||
process() { | ||
return 'module.exports = {};' | ||
}, | ||
getCacheKey() { | ||
// The output is always the same. | ||
return 'cssTransform' | ||
}, | ||
} |
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,40 @@ | ||
'use strict' | ||
|
||
const path = require('path') | ||
const camelcase = require('camelcase') | ||
|
||
// This is a custom Jest transformer turning file imports into filenames. | ||
// http://facebook.github.io/jest/docs/en/webpack.html | ||
|
||
module.exports = { | ||
process(src, filename) { | ||
const assetFilename = JSON.stringify(path.basename(filename)) | ||
|
||
if (filename.match(/\.svg$/)) { | ||
// Based on how SVGR generates a component name: | ||
// https://github.com/smooth-code/svgr/blob/01b194cf967347d43d4cbe6b434404731b87cf27/packages/core/src/state.js#L6 | ||
const pascalCaseFilename = camelcase(path.parse(filename).name, { | ||
pascalCase: true, | ||
}) | ||
const componentName = `Svg${pascalCaseFilename}` | ||
return `const React = require('react') | ||
module.exports = { | ||
__esModule: true, | ||
default: ${assetFilename}, | ||
ReactComponent: React.forwardRef(function ${componentName}(props, ref) { | ||
return { | ||
$$typeof: Symbol.for('react.element'), | ||
type: 'svg', | ||
ref: ref, | ||
key: null, | ||
props: Object.assign({}, props, { | ||
children: ${assetFilename} | ||
}) | ||
} | ||
}), | ||
}` | ||
} | ||
|
||
return `module.exports = ${assetFilename}` | ||
}, | ||
} |
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
65 changes: 65 additions & 0 deletions
65
...ages/elements-next/src/components/headings/__tests__/__snapshots__/headings.test.tsx.snap
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,65 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`headings HeadingMain should match snapshot when have props 1`] = ` | ||
<h1 | ||
className="" | ||
> | ||
mockHeading | ||
</h1> | ||
`; | ||
|
||
exports[`headings HeadingMain should match snapshot when no props 1`] = ` | ||
<h1 | ||
className="" | ||
> | ||
mockHeading | ||
</h1> | ||
`; | ||
|
||
exports[`headings HeadingSecondary should match snapshot when have props 1`] = ` | ||
<h4 | ||
className="" | ||
> | ||
Mock Heading | ||
</h4> | ||
`; | ||
|
||
exports[`headings HeadingSecondary should match snapshot when no props 1`] = ` | ||
<h4 | ||
className="" | ||
> | ||
Mock Heading | ||
</h4> | ||
`; | ||
|
||
exports[`headings SubHeadingMain should match snapshot when have props 1`] = ` | ||
<h3 | ||
className="" | ||
> | ||
Mock Heading | ||
</h3> | ||
`; | ||
|
||
exports[`headings SubHeadingMain should match snapshot when no props 1`] = ` | ||
<h3 | ||
className="" | ||
> | ||
Mock Heading | ||
</h3> | ||
`; | ||
|
||
exports[`headings SubHeadingSecondary should match snapshot when have props 1`] = ` | ||
<h6 | ||
className="" | ||
> | ||
Mock Heading | ||
</h6> | ||
`; | ||
|
||
exports[`headings SubHeadingSecondary should match snapshot when no props 1`] = ` | ||
<h6 | ||
className="" | ||
> | ||
Mock Heading | ||
</h6> | ||
`; |
69 changes: 69 additions & 0 deletions
69
packages/elements-next/src/components/headings/__tests__/headings.test.tsx
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,69 @@ | ||
import React from 'react' | ||
import { shallow } from 'enzyme' | ||
import { HeadingMain, HeadingSecondary, SubHeadingMain, SubHeadingSecondary } from '../headings' | ||
|
||
describe('headings', () => { | ||
describe('HeadingMain', () => { | ||
it('should match snapshot when have props', () => { | ||
const wrapper = shallow( | ||
<HeadingMain className="mockClassName" isTextCentered={true}> | ||
mockHeading | ||
</HeadingMain>, | ||
) | ||
expect(wrapper).toMatchSnapshot() | ||
}) | ||
|
||
it('should match snapshot when no props', () => { | ||
const wrapper = shallow(<HeadingMain>mockHeading</HeadingMain>) | ||
expect(wrapper).toMatchSnapshot() | ||
}) | ||
}) | ||
|
||
describe('SubHeadingMain', () => { | ||
it('should match snapshot when have props', () => { | ||
const wrapper = shallow( | ||
<SubHeadingMain className="mockClassName" isTextCentered={true}> | ||
Mock Heading | ||
</SubHeadingMain>, | ||
) | ||
expect(wrapper).toMatchSnapshot() | ||
}) | ||
|
||
it('should match snapshot when no props', () => { | ||
const wrapper = shallow(<SubHeadingMain>Mock Heading</SubHeadingMain>) | ||
expect(wrapper).toMatchSnapshot() | ||
}) | ||
}) | ||
|
||
describe('HeadingSecondary', () => { | ||
it('should match snapshot when have props', () => { | ||
const wrapper = shallow( | ||
<HeadingSecondary className="mockClassName" isTextCentered={true}> | ||
Mock Heading | ||
</HeadingSecondary>, | ||
) | ||
expect(wrapper).toMatchSnapshot() | ||
}) | ||
|
||
it('should match snapshot when no props', () => { | ||
const wrapper = shallow(<HeadingSecondary>Mock Heading</HeadingSecondary>) | ||
expect(wrapper).toMatchSnapshot() | ||
}) | ||
}) | ||
|
||
describe('SubHeadingSecondary', () => { | ||
it('should match snapshot when have props', () => { | ||
const wrapper = shallow( | ||
<SubHeadingSecondary className="mockClassName" isTextCentered={true}> | ||
Mock Heading | ||
</SubHeadingSecondary>, | ||
) | ||
expect(wrapper).toMatchSnapshot() | ||
}) | ||
|
||
it('should match snapshot when no props', () => { | ||
const wrapper = shallow(<SubHeadingSecondary>Mock Heading</SubHeadingSecondary>) | ||
expect(wrapper).toMatchSnapshot() | ||
}) | ||
}) | ||
}) |
16 changes: 10 additions & 6 deletions
16
packages/elements-next/src/components/headings/headings.mdx
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,19 +1,23 @@ | ||
--- | ||
name: Headings | ||
name: Heading | ||
route: /headings | ||
--- | ||
|
||
import { Playground, Props } from 'docz' | ||
import { HeadingMain } from './headings' | ||
import { Heading } from './headings' | ||
import { DocsWrapper } from '@/utils/docs-wrapper' | ||
|
||
# Headings | ||
|
||
<Props of={HeadingMain} /> | ||
# Heading | ||
## Document | ||
<Props of={Heading.Main} /> | ||
|
||
## Usage | ||
<Playground> | ||
<DocsWrapper> | ||
<HeadingMain>Heading Main</HeadingMain> | ||
<Heading.Main>Heading Main</Heading.Main> | ||
<Heading.SubMain>SubHeading Main</Heading.SubMain> | ||
<Heading.Secondary>Heading Secondary</Heading.Secondary> | ||
<Heading.SubSecondary>SubHeading Secondary</Heading.SubSecondary> | ||
</DocsWrapper> | ||
</Playground> | ||
|
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 +1 @@ | ||
export * from './headings' | ||
export { default } from './headings' |
19 changes: 19 additions & 0 deletions
19
packages/elements-next/src/components/modal/__styles__/index.ts
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,19 @@ | ||
import { css } from 'linaria' | ||
|
||
export const modalContainer = css` | ||
.rc-dialog-content { | ||
border-radius: 0; | ||
} | ||
.rc-dialog-header { | ||
background-color: #f5f5f5; | ||
} | ||
.rc-dialog-footer { | ||
background-color: #f5f5f5; | ||
} | ||
` | ||
|
||
export const modalCentered = css` | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
` |
Oops, something went wrong.