Skip to content
Merged
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
3 changes: 1 addition & 2 deletions .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
"plugins": [
"@babel/plugin-transform-runtime",
"@babel/plugin-proposal-class-properties",
"babel-plugin-add-react-displayname",
"babel-plugin-typescript-to-proptypes"
"babel-plugin-add-react-displayname"
],
"env": {
"esm": {
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@
"babel-eslint": "^10.0.1",
"babel-loader": "^8.0.5",
"babel-plugin-add-react-displayname": "^0.0.5",
"babel-plugin-typescript-to-proptypes": "^0.17.1",
"concurrently": "^4.0.1",
"enzyme": "^3.7.0",
"enzyme-adapter-react-16": "^1.6.0",
Expand Down
2 changes: 1 addition & 1 deletion src/text-input/src/TextInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class TextInput extends PureComponent<any & React.ComponentProps<typeof Text>> {
theme: PropTypes.object.isRequired,

/**
* Class name passed to the button.
* Class name passed to the input.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:)

* Only use if you know what you are doing.
*/
className: PropTypes.string
Expand Down
2 changes: 1 addition & 1 deletion src/textarea/src/Textarea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class Textarea extends PureComponent<any & React.ComponentProps<typeof Text>> {
theme: PropTypes.object.isRequired,

/**
* Class name passed to the button.
* Class name passed to the textarea.
* Only use if you know what you are doing.
*/
className: PropTypes.string
Expand Down
48 changes: 29 additions & 19 deletions src/typography/src/Code.tsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,39 @@
import React, { PureComponent } from 'react'
import React, { PureComponent, Validator } from 'react'
import PropTypes from 'prop-types'
import cx from 'classnames'
import { withTheme } from '../../theme'
import { withTheme, Theme } from '../../theme'
import Text from './Text'

class Code extends PureComponent<any & React.ComponentProps<typeof Text>> {
type Appearance = 'default' | 'minimal'

export interface CodeProps extends React.ComponentProps<typeof Text> {
/**
* The appearance of the code.
*/
appearance: Appearance

/**
* Class name passed to the component.
* Only use if you know what you are doing.
*/
className?: string

/**
* Theme provided by ThemeProvider.
*/
theme: Theme
}

class Code extends PureComponent<CodeProps> {
static propTypes = {
/**
* The appearance of the code.
*/
appearance: PropTypes.oneOf(['default', 'minimal']).isRequired,

/**
* Theme provided by ThemeProvider.
*/
theme: PropTypes.object.isRequired,

/**
* Class name passed to the button.
* Only use if you know what you are doing.
*/
className: PropTypes.string
appearance: PropTypes.oneOf(['default', 'minimal']).isRequired as Validator<
Appearance
>,
className: PropTypes.string,
theme: PropTypes.object.isRequired as Validator<Theme>
}

static defaultProps = {
static defaultProps: Partial<CodeProps> = {
appearance: 'default'
}

Expand Down
44 changes: 26 additions & 18 deletions src/typography/src/Heading.tsx
Original file line number Diff line number Diff line change
@@ -1,32 +1,40 @@
import React, { PureComponent } from 'react'
import React, { PureComponent, Validator } from 'react'
import PropTypes from 'prop-types'
import Box from 'ui-box'
import { withTheme } from '../../theme'
import { withTheme, Theme } from '../../theme'

class Heading extends PureComponent<any & React.ComponentProps<typeof Box>> {
static propTypes = {
/**
* The size of the heading.
*/
size: PropTypes.oneOf([100, 200, 300, 400, 500, 600, 700, 800, 900])
.isRequired,
type HeadingSize = 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900

export interface HeadingProps extends React.ComponentProps<typeof Box> {
/**
* Pass `default` to use the default margin top for that size.
*/
marginTop?: boolean | number | string | 'default'

/**
* Pass `default` to use the default margin top for that size.
*/
/**
* The size of the heading.
*/
size: HeadingSize

/**
* Theme provided by ThemeProvider.
*/
theme: Theme
}

class Heading extends PureComponent<HeadingProps> {
static propTypes = {
marginTop: PropTypes.oneOfType([
PropTypes.bool,
PropTypes.number,
PropTypes.string
]),

/**
* Theme provided by ThemeProvider.
*/
theme: PropTypes.object.isRequired
size: PropTypes.oneOf([100, 200, 300, 400, 500, 600, 700, 800, 900])
.isRequired as Validator<HeadingSize>,
theme: PropTypes.object.isRequired as Validator<Theme>
}

static defaultProps = {
static defaultProps: Partial<HeadingProps> = {
size: 500
}

Expand Down
8 changes: 5 additions & 3 deletions src/typography/src/Label.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import React, { PureComponent } from 'react'
import Text from './Text'

export default class Label extends PureComponent<
React.ComponentProps<typeof Text>
> {
export interface LabelProps extends React.ComponentProps<typeof Text> {}

export default class Label extends PureComponent<LabelProps> {
static propTypes = Text.propTypes

render() {
return <Text is="label" fontWeight={500} {...this.props} />
}
Expand Down
73 changes: 41 additions & 32 deletions src/typography/src/Link.tsx
Original file line number Diff line number Diff line change
@@ -1,42 +1,51 @@
import React, { PureComponent } from 'react'
import React, { PureComponent, Validator } from 'react'
import PropTypes from 'prop-types'
import cx from 'classnames'
import { withTheme } from '../../theme'
import { withTheme, Theme } from '../../theme'
import Text from './Text'

class Link extends PureComponent<any & React.ComponentProps<typeof Text>> {
static propTypes = {
/**
* This attribute names a relationship of the linked document to the current document.
* Common use case is: rel="noopener noreferrer".
*/
rel: PropTypes.string,
export interface LinkProps extends React.ComponentProps<typeof Text> {
/**
* Class name passed to the link.
* Only use if you know what you are doing.
*/
className?: string

/**
* Specifies the URL of the linked resource. A URL might be absolute or relative.
*/
href: PropTypes.string,
/**
* The color (and styling) of the Link. Can be default, blue, green or neutral.
*/
color?: string

/**
* Target atrribute, common use case is target="_blank."
*/
target: PropTypes.string,
/**
* Specifies the URL of the linked resource. A URL might be absolute or relative.
*/
href?: string

/**
* This attribute names a relationship of the linked document to the current document.
* Common use case is: rel="noopener noreferrer".
*/
rel?: string

/**
* Target atrribute, common use case is target="_blank."
*/
target?: string

/**
* The color (and styling) of the Link. Can be default, blue, green or neutral.
*/
color: PropTypes.string.isRequired,

/**
* Theme provided by ThemeProvider.
*/
theme: PropTypes.object.isRequired,

/**
* Class name passed to the link.
* Only use if you know what you are doing.
*/
className: PropTypes.string
/**
* Theme provided by ThemeProvider.
*/
theme: Theme
}

class Link extends PureComponent<LinkProps> {
static propTypes = {
className: PropTypes.string,
color: PropTypes.string,
href: PropTypes.string,
rel: PropTypes.string,
target: PropTypes.string,
theme: PropTypes.object.isRequired as Validator<Theme>
}

static defaultProps = {
Expand Down
26 changes: 15 additions & 11 deletions src/typography/src/ListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,23 @@ import PropTypes from 'prop-types'
import { Icon } from '../../icon'
import Text from './Text'

export default class ListItem extends PureComponent<
any & React.ComponentProps<typeof Text>
> {
export interface ListItemProps extends React.ComponentProps<typeof Text> {
/**
* When passed, adds a icon before the list item.
* See Evergreen `Icon` for documentation.
*/
icon?: string

/**
* The color of the icon.
*/
iconColor?: string
}

export default class ListItem extends PureComponent<ListItemProps> {
static propTypes = {
/**
* When passed, adds a icon before the list item.
* See Evergreen `Icon` for documentation.
*/
...Text.propTypes,
icon: PropTypes.string,

/**
* The color of the icon.
*/
iconColor: PropTypes.string
}

Expand Down
22 changes: 13 additions & 9 deletions src/typography/src/OrderedList.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
import React, { PureComponent } from 'react'
import React, { PureComponent, Validator } from 'react'
import PropTypes from 'prop-types'
import Box from 'ui-box'

export default class OrderedList extends PureComponent<
any & React.ComponentProps<typeof Box>
> {
type ListSize = 300 | 400 | 500 | 600

export interface OrderedListProps extends React.ComponentProps<typeof Box> {
/**
* Size of the text used in a list item.
* Can be: 300, 400, 500, 600.
*/
size: ListSize
}

export default class OrderedList extends PureComponent<OrderedListProps> {
static propTypes = {
/**
* Size of the text used in a list item.
* Can be: 300, 400, 500, 600.
*/
size: PropTypes.oneOf([300, 400, 500, 600]).isRequired
size: PropTypes.number as Validator<ListSize>
}

static defaultProps = {
Expand Down
57 changes: 37 additions & 20 deletions src/typography/src/Paragraph.tsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,46 @@
import React, { PureComponent } from 'react'
import React, { PureComponent, Validator } from 'react'
import PropTypes from 'prop-types'
import Box from 'ui-box'
import { withTheme } from '../../theme'
import { withTheme, Theme } from '../../theme'

class Paragraph extends PureComponent<any & React.ComponentProps<typeof Box>> {
type FontFamily = 'ui' | 'display' | 'mono'
type ParagraphSize = 300 | 400 | 500

export interface ParagraphProps extends React.ComponentProps<typeof Box> {
/**
* The color (alias or valid color) applied to the text
*/
color?: string

/**
* Font family.
* Can be: `ui`, `display` or `mono` or a custom font family.
*/
fontFamily?: FontFamily

/**
* Size of the text style.
* Can be: 300, 400, 500.
*/
size?: ParagraphSize

/**
* Theme provided by ThemeProvider.
*/
theme: Theme
}

class Paragraph extends PureComponent<ParagraphProps> {
static propTypes = {
/**
* Size of the text style.
* Can be: 300, 400, 500.
*/
size: PropTypes.oneOf([300, 400, 500]).isRequired,

/**
* Font family.
* Can be: `ui`, `display` or `mono` or a custom font family.
*/
fontFamily: PropTypes.string.isRequired,

/**
* Theme provided by ThemeProvider.
*/
theme: PropTypes.object.isRequired
color: PropTypes.string,
fontFamily: PropTypes.oneOf(['ui', 'display', 'mono']) as Validator<
FontFamily
>,
size: PropTypes.oneOf([300, 400, 500, 600]) as Validator<ParagraphSize>,
theme: PropTypes.object.isRequired as Validator<Theme>
}

static defaultProps = {
static defaultProps: Partial<ParagraphProps> = {
size: 400,
color: 'default',
fontFamily: 'ui'
Expand Down
8 changes: 5 additions & 3 deletions src/typography/src/Pre.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import React, { PureComponent } from 'react'
import Text from './Text'

export default class Pre extends PureComponent<
React.ComponentProps<typeof Text>
> {
export interface PreProps extends React.ComponentProps<typeof Text> {}

export default class Pre extends PureComponent<PreProps> {
static propTypes = Text.propTypes

render() {
return <Text is="pre" marginTop={0} marginBottom={0} {...this.props} />
}
Expand Down
Loading