From 80811c9ccacc646188821b1b31aeaa017e40e9a0 Mon Sep 17 00:00:00 2001 From: Ezekiel Aquino Date: Mon, 10 Dec 2018 11:52:42 +0100 Subject: Async load icons, adds margins --- packages/website/ts/@next/components/icon.tsx | 26 +++++++++++++++++------ packages/website/ts/@next/constants/utilities.tsx | 2 +- packages/website/ts/@next/pages/landing.tsx | 9 ++++++-- 3 files changed, 27 insertions(+), 10 deletions(-) (limited to 'packages/website/ts') diff --git a/packages/website/ts/@next/components/icon.tsx b/packages/website/ts/@next/components/icon.tsx index 8dfede88c..60e27f07e 100644 --- a/packages/website/ts/@next/components/icon.tsx +++ b/packages/website/ts/@next/components/icon.tsx @@ -1,18 +1,19 @@ import * as React from 'react'; +import Loadable from 'react-loadable'; import styled from 'styled-components'; -import IconCoin from 'ts/@next/icons/illustrations/coin.svg'; +import {getCSSPadding} from 'ts/@next/constants/utilities'; -interface Props { +interface IconProps { name: string; + margin?: Array<'small' | 'default' | 'large' | number> | number; size?: 'small' | 'medium' | 'large' | number; } -const ICONS = { - coin: IconCoin, -}; - export const Icon: React.FunctionComponent = (props: Props) => { - const IconSVG = ICONS[props.name]; + const IconSVG = Loadable({ + loader: () => import(`ts/@next/icons/illustrations/${props.name}.svg`), + loading: () => 'Loading', + }); return ( @@ -21,6 +22,17 @@ export const Icon: React.FunctionComponent = (props: Props) => { ); }; +export const InlineIconWrap = styled.div` + margin: ${props => getCSSPadding(props.margin)}; + display: flex; + align-items: center; + justify-content: center; + + > figure { + margin: 0 5px; + } +`; + const _getSize = (size: string | number = 'small'): string => { if (isNaN(size)) { return `var(--${size}Icon)`; diff --git a/packages/website/ts/@next/constants/utilities.tsx b/packages/website/ts/@next/constants/utilities.tsx index 35956c47b..74f121e49 100644 --- a/packages/website/ts/@next/constants/utilities.tsx +++ b/packages/website/ts/@next/constants/utilities.tsx @@ -1,5 +1,5 @@ export interface PaddingInterface { - padding?: number | Array<'large' | 'default' | number>; + padding?: number | Array<'large' | 'default', 'small' | number>; } interface PaddingSizes { diff --git a/packages/website/ts/@next/pages/landing.tsx b/packages/website/ts/@next/pages/landing.tsx index d4ad55b9d..b884c3545 100644 --- a/packages/website/ts/@next/pages/landing.tsx +++ b/packages/website/ts/@next/pages/landing.tsx @@ -5,7 +5,7 @@ import styled from 'styled-components'; import {colors} from 'ts/style/colors'; import {Button, ButtonWrap} from 'ts/@next/components/button'; -import {Icon} from 'ts/@next/components/icon'; +import {Icon, InlineIconWrap} from 'ts/@next/components/icon'; import {Column, Section, Wrap, WrapCentered, WrapGrid} from 'ts/@next/components/layout'; import {SiteWrap} from 'ts/@next/components/siteWrap'; import {Heading, Paragraph} from 'ts/@next/components/text'; @@ -94,7 +94,12 @@ export const NextLanding: React.StatelessComponent<{}> = () => (
- + + + + + +