From 60287779d9fd8574c0d9526063364ea7236700e4 Mon Sep 17 00:00:00 2001 From: Alexandru Buliga Date: Tue, 31 Jul 2018 19:39:26 +0200 Subject: [PATCH 01/14] fix: Component interfaces extend React attributes --- src/components/Button/Button.tsx | 4 +--- src/components/Icon/Icon.tsx | 8 ++------ src/components/Text/Text.tsx | 2 -- src/lib/UIComponent.tsx | 9 +++++++-- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/components/Button/Button.tsx b/src/components/Button/Button.tsx index 7c32d4ac55..bbc26af745 100644 --- a/src/components/Button/Button.tsx +++ b/src/components/Button/Button.tsx @@ -1,5 +1,5 @@ import PropTypes from 'prop-types' -import React, { ReactNode, CSSProperties, SyntheticEvent } from 'react' +import React, { ReactNode, SyntheticEvent } from 'react' import { UIComponent, childrenExist, customPropTypes, IRenderResultConfig } from '../../lib' import buttonRules from './buttonRules' @@ -11,7 +11,6 @@ export type IconPosition = 'before' | 'after' export type ButtonType = 'primary' | 'secondary' export interface IButtonProps { - as?: string children?: ReactNode circular?: boolean className?: string @@ -21,7 +20,6 @@ export interface IButtonProps { icon?: boolean | string iconPosition?: IconPosition onClick?: (e: SyntheticEvent, props: IButtonProps) => void - style?: CSSProperties type?: ButtonType } diff --git a/src/components/Icon/Icon.tsx b/src/components/Icon/Icon.tsx index 1e7875efe4..b88f1bca0d 100644 --- a/src/components/Icon/Icon.tsx +++ b/src/components/Icon/Icon.tsx @@ -1,4 +1,4 @@ -import React, { CSSProperties } from 'react' +import React, { HTMLAttributes } from 'react' import PropTypes from 'prop-types' import { customPropTypes, UIComponent, SUI } from '../../lib' @@ -25,19 +25,15 @@ export type IconSize = 'mini' | 'tiny' | 'small' | 'large' | 'big' | 'huge' | 'm export type IconXSpacing = 'none' | 'before' | 'after' | 'both' -export interface IconProps { - as?: string +export interface IconProps extends HTMLAttributes { bordered?: boolean circular?: boolean - className?: string color?: IconColor disabled?: boolean kind?: string name?: string size?: IconSize xSpacing?: IconXSpacing - style?: CSSProperties - title?: string } class Icon extends UIComponent { diff --git a/src/components/Text/Text.tsx b/src/components/Text/Text.tsx index 69523e90f4..ea92e9de74 100644 --- a/src/components/Text/Text.tsx +++ b/src/components/Text/Text.tsx @@ -8,9 +8,7 @@ import textVariables from './textVariables' export type ITextSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2x' | '3x' | '4x' export interface ITextProps { - as?: string atMention?: boolean - className?: string content?: ReactNode disabled?: boolean error?: boolean diff --git a/src/lib/UIComponent.tsx b/src/lib/UIComponent.tsx index efd20cd4f1..c8db72084c 100644 --- a/src/lib/UIComponent.tsx +++ b/src/lib/UIComponent.tsx @@ -1,7 +1,12 @@ -import React from 'react' +import React, { HTMLAttributes } from 'react' import renderComponent, { IRenderResultConfig } from './renderComponent' -class UIComponent extends React.Component { +export interface UIComponentProps extends HTMLAttributes { + as?: string | Function + variables?: (siteVariables: object) => object +} + +class UIComponent extends React.Component

{ private readonly childClass = this.constructor as typeof UIComponent static defaultProps: { [key: string]: any } static displayName: string From 7813cacdb607f5d6fffa1fff369e20ee7d008fb9 Mon Sep 17 00:00:00 2001 From: manajdov Date: Wed, 1 Aug 2018 10:53:45 +0200 Subject: [PATCH 02/14] -fixing types --- src/components/Avatar/Avatar.tsx | 4 ++-- src/components/Avatar/avatarRules.ts | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/components/Avatar/Avatar.tsx b/src/components/Avatar/Avatar.tsx index c2166616f5..43a493e193 100644 --- a/src/components/Avatar/Avatar.tsx +++ b/src/components/Avatar/Avatar.tsx @@ -100,7 +100,7 @@ class Avatar extends UIComponent { className={classes.avatarLabel} as="div" content={this.getInitials(name)} - variables={{ padding: '0px' }} + variables={() => ({ padding: '0px' })} circular title={name} /> @@ -110,7 +110,7 @@ class Avatar extends UIComponent {

From b2b0f875d657574864eab419784d2588a7ddf131 Mon Sep 17 00:00:00 2001 From: manajdov Date: Wed, 1 Aug 2018 11:42:48 +0200 Subject: [PATCH 04/14] -added variables prop to the Label component --- src/components/Label/Label.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/Label/Label.tsx b/src/components/Label/Label.tsx index e4e8e2e8ce..ff621bd00f 100644 --- a/src/components/Label/Label.tsx +++ b/src/components/Label/Label.tsx @@ -31,9 +31,12 @@ class Label extends UIComponent { /** Shorthand for primary content. */ content: customPropTypes.contentShorthand, + + /** Function for overriding the variables for the component. */ + variables: PropTypes.func, } - static handledProps = ['as', 'children', 'circular', 'className', 'content'] + static handledProps = ['as', 'children', 'circular', 'className', 'content', 'variables'] static defaultProps = { as: 'label', From 799677e90806aa2c61805801a59d40cf6505e1d3 Mon Sep 17 00:00:00 2001 From: manajdov Date: Wed, 1 Aug 2018 12:05:00 +0200 Subject: [PATCH 05/14] -added props interface to the Label component --- src/components/Label/Label.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/components/Label/Label.tsx b/src/components/Label/Label.tsx index ff621bd00f..350e52c3c6 100644 --- a/src/components/Label/Label.tsx +++ b/src/components/Label/Label.tsx @@ -1,15 +1,20 @@ import PropTypes from 'prop-types' -import React from 'react' +import React, { HTMLAttributes, ReactNode } from 'react' import { childrenExist, createShorthandFactory, customPropTypes, UIComponent } from '../../lib' import labelRules from './labelRules' import labelVariables from './labelVariables' +export interface LabelProps extends HTMLAttributes { + circular?: boolean + content?: ReactNode +} + /** * A label displays content classification */ -class Label extends UIComponent { +class Label extends UIComponent { static displayName = 'Label' static create: Function From 4800164db99e8d2ef3b334fc6341dce5353c0c3e Mon Sep 17 00:00:00 2001 From: manajdov Date: Wed, 1 Aug 2018 12:14:27 +0200 Subject: [PATCH 06/14] -fixes --- src/components/Icon/Icon.tsx | 4 ++-- src/components/Label/Label.tsx | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/Icon/Icon.tsx b/src/components/Icon/Icon.tsx index b88f1bca0d..7f4f6f13c1 100644 --- a/src/components/Icon/Icon.tsx +++ b/src/components/Icon/Icon.tsx @@ -1,4 +1,4 @@ -import React, { HTMLAttributes } from 'react' +import React from 'react' import PropTypes from 'prop-types' import { customPropTypes, UIComponent, SUI } from '../../lib' @@ -25,7 +25,7 @@ export type IconSize = 'mini' | 'tiny' | 'small' | 'large' | 'big' | 'huge' | 'm export type IconXSpacing = 'none' | 'before' | 'after' | 'both' -export interface IconProps extends HTMLAttributes { +export interface IconProps { bordered?: boolean circular?: boolean color?: IconColor diff --git a/src/components/Label/Label.tsx b/src/components/Label/Label.tsx index 350e52c3c6..c79fad9e89 100644 --- a/src/components/Label/Label.tsx +++ b/src/components/Label/Label.tsx @@ -6,7 +6,7 @@ import { childrenExist, createShorthandFactory, customPropTypes, UIComponent } f import labelRules from './labelRules' import labelVariables from './labelVariables' -export interface LabelProps extends HTMLAttributes { +export interface LabelProps { circular?: boolean content?: ReactNode } From 0fc3605eea7d3593f9bfb0df8ba7ea16406b3945 Mon Sep 17 00:00:00 2001 From: manajdov Date: Wed, 1 Aug 2018 14:38:24 +0200 Subject: [PATCH 07/14] -reverted changes in the avatar examples --- .../Variations/AvatarExampleAlt.shorthand.tsx | 2 +- .../Variations/AvatarExampleSize.shorthand.tsx | 2 +- .../Variations/AvatarExampleSrc.shorthand.tsx | 2 +- .../Variations/AvatarExampleStatus.shorthand.tsx | 14 +++++++------- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/src/examples/components/Avatar/Variations/AvatarExampleAlt.shorthand.tsx b/docs/src/examples/components/Avatar/Variations/AvatarExampleAlt.shorthand.tsx index 842ac34ca2..ab1dce3397 100644 --- a/docs/src/examples/components/Avatar/Variations/AvatarExampleAlt.shorthand.tsx +++ b/docs/src/examples/components/Avatar/Variations/AvatarExampleAlt.shorthand.tsx @@ -2,7 +2,7 @@ import React from 'react' import { Avatar } from '@stardust-ui/react' const AvatarExampleAltShorthand = () => ( - + ) export default AvatarExampleAltShorthand diff --git a/docs/src/examples/components/Avatar/Variations/AvatarExampleSize.shorthand.tsx b/docs/src/examples/components/Avatar/Variations/AvatarExampleSize.shorthand.tsx index 6a24b498f3..9842145d24 100644 --- a/docs/src/examples/components/Avatar/Variations/AvatarExampleSize.shorthand.tsx +++ b/docs/src/examples/components/Avatar/Variations/AvatarExampleSize.shorthand.tsx @@ -11,7 +11,7 @@ const AvatarExampleSizeShorthand = () =>
diff --git a/docs/src/examples/components/Avatar/Variations/AvatarExampleSrc.shorthand.tsx b/docs/src/examples/components/Avatar/Variations/AvatarExampleSrc.shorthand.tsx index 9e7792d8b1..0a65e19232 100644 --- a/docs/src/examples/components/Avatar/Variations/AvatarExampleSrc.shorthand.tsx +++ b/docs/src/examples/components/Avatar/Variations/AvatarExampleSrc.shorthand.tsx @@ -1,6 +1,6 @@ import React from 'react' import { Avatar } from '@stardust-ui/react' -const AvatarExampleSrcShorthand = () => +const AvatarExampleSrcShorthand = () => export default AvatarExampleSrcShorthand diff --git a/docs/src/examples/components/Avatar/Variations/AvatarExampleStatus.shorthand.tsx b/docs/src/examples/components/Avatar/Variations/AvatarExampleStatus.shorthand.tsx index ac743e6064..27c68659a0 100644 --- a/docs/src/examples/components/Avatar/Variations/AvatarExampleStatus.shorthand.tsx +++ b/docs/src/examples/components/Avatar/Variations/AvatarExampleStatus.shorthand.tsx @@ -4,37 +4,37 @@ import { Avatar } from '@stardust-ui/react' const AvatarExampleStatusShorthand = () => (
From 9a39575ab0e3a3c34c2a285d5a62be1444d5676d Mon Sep 17 00:00:00 2001 From: manajdov Date: Wed, 1 Aug 2018 19:01:51 +0200 Subject: [PATCH 08/14] -fixed variables type to work with object too --- src/components/Avatar/Avatar.tsx | 4 ++-- src/lib/UIComponent.tsx | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/Avatar/Avatar.tsx b/src/components/Avatar/Avatar.tsx index 43a493e193..c2166616f5 100644 --- a/src/components/Avatar/Avatar.tsx +++ b/src/components/Avatar/Avatar.tsx @@ -100,7 +100,7 @@ class Avatar extends UIComponent { className={classes.avatarLabel} as="div" content={this.getInitials(name)} - variables={() => ({ padding: '0px' })} + variables={{ padding: '0px' }} circular title={name} /> @@ -110,7 +110,7 @@ class Avatar extends UIComponent {