Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(components): extract icons to separate package #571

Merged
merged 47 commits into from
Apr 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
f9923a0
fix(components): prevent background from scrolling when modal is open…
connor-baer Jan 23, 2020
0f8d642
fix(components): add top margin to Select below Label (#532)
nicosommi Jan 24, 2020
678a0ca
Fix hamburger typos (#536)
larimaza Jan 29, 2020
289c1a2
fix(components): remove scrollbar from LoadingButton (#542)
connor-baer Jan 31, 2020
78a972d
chore(deploy): fix automatic deployment to GitHub Pages (#540)
connor-baer Feb 19, 2020
b6a60ff
docs: fix Storybook links (#547)
connor-baer Feb 23, 2020
f977b8d
feat(components): add support for async filtering to AutoCompleteInpu…
connor-baer Mar 4, 2020
5795ea1
fix(components): remove invalid Button props from HTML (#548)
dmitri-suvorov-sumup Mar 4, 2020
2b6ac1a
fix(components): fill invalid radio button with red to match checkbox…
larimaza Mar 11, 2020
bf3a8f9
fix(components): replace reset icon on SearchInput component (#555)
connor-baer Mar 27, 2020
e4caf10
docs: show addons panel by default (#557)
connor-baer Mar 30, 2020
12bf0e9
fix(components): make AutocompleteInput compatible with new clear opt…
connor-baer Mar 30, 2020
2ca9803
feat(components): improve clear button on inputs (#559)
connor-baer Mar 30, 2020
e2c14e1
fix(components): remove default prop to silence deprecation warning
connor-baer Mar 30, 2020
2ddf5be
fix(components): add styles to the card elements in card stories
justman00 Apr 1, 2020
5fbe011
feat(components): pass initial value to AutocompleteInput (#562)
connor-baer Apr 2, 2020
9cbf2e2
feat(components): refactor AutoCompleteTags (#561)
marielakas Apr 7, 2020
85019ca
fix(components): update clearfix to improve accessibility (#565)
dmitri-suvorov-sumup Apr 13, 2020
6510000
chore(configs): disable security script on Travis
connor-baer Apr 13, 2020
ac3650e
feat(components): update InfoIcon (#567)
marielakas Apr 14, 2020
badd14a
feat(components): Toggle component - ability to be right aligned (#570)
hrstngrnvsmp Apr 22, 2020
03aa6ca
feat(components): add optional suffix to the Tag component (#566)
marielakas Apr 22, 2020
b3d89f4
fix(components): reduce icon margin on Tag (#573)
marielakas Apr 22, 2020
11b0fec
Merge branch 'master' into alpha
connor-baer Apr 29, 2020
1f2badb
feat(components): remove deprecated props
connor-baer Apr 29, 2020
060eb10
feat(configs): install @sumup/icons
connor-baer Apr 19, 2020
9091755
docs(docs): add page with icon search
connor-baer Apr 19, 2020
cf4500a
feat(components): remove CardSchemes and PaymentMethodIcon components
connor-baer Apr 19, 2020
8dbf07d
feat(components): remove InfoIcon component
connor-baer Apr 19, 2020
960a55d
feat(components): replace SVGs in CloseButton
connor-baer Apr 19, 2020
9e9a2f6
feat(components): rewrite Spinner in pure CSS
connor-baer Apr 19, 2020
2f1b58b
feat(components): update LoadingButton with new Spinner
connor-baer Apr 19, 2020
27a5538
feat(components): replace SVGs in Input components
connor-baer Apr 19, 2020
18b2c6a
feat(components): replace SVG in Checkbox component
connor-baer Apr 19, 2020
9f0200a
feat(components): replace SVGs in Select component
connor-baer Apr 19, 2020
4c79533
feat(components): replace SVGs in Notification component
connor-baer Apr 19, 2020
0376e9f
feat(components): replace SVGs in Calendar components
connor-baer Apr 19, 2020
acd9028
feat(components): replace SVG in Table component
connor-baer Apr 19, 2020
2f5aeb3
feat(components): replace SVGs in Sidebar components
connor-baer Apr 19, 2020
c701d28
WIP: replace SVGs in Carousel components
connor-baer Apr 19, 2020
ad2a135
test(components): update storyshots
connor-baer Apr 19, 2020
62134c4
test(components): temporarily disable a11y test
connor-baer Apr 20, 2020
336c3b8
docs(docs): update icon color options
connor-baer Apr 20, 2020
a02736e
feat(components): update icons to latest versions
connor-baer Apr 28, 2020
7a88dec
test(configs): fix typo in coverage config
connor-baer Apr 28, 2020
7a7d4c8
feat: update @sumup/icons to latest
connor-baer Apr 29, 2020
a158972
feat: update @sumup/icons to latest
connor-baer Apr 29, 2020
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
7 changes: 1 addition & 6 deletions .storybook/.babelrc
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
{
"plugins": [
"@babel/plugin-proposal-class-properties",
"lodash",
"inline-react-svg",
"macros"
],
"plugins": ["@babel/plugin-proposal-class-properties", "lodash", "macros"],
"presets": [
["@babel/preset-env", { "loose": true }],
"@babel/preset-react",
Expand Down
2 changes: 0 additions & 2 deletions .storybook/components/IconSize.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ const IconSize = ({ size }) => (
);

IconSize.propTypes = {
// eslint-disable-next-line
theme: PropTypes.object.isRequired,
size: PropTypes.string.isRequired
};

Expand Down
189 changes: 189 additions & 0 deletions .storybook/components/Icons.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
/**
* Copyright 2019, SumUp Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import React, { useState } from 'react';
import PropTypes from 'prop-types';
import styled from '@emotion/styled';
import { css } from '@emotion/core';
import { ThemeProvider } from 'emotion-theming';
import { keys, entries, includes, isEmpty, groupBy, sortBy } from 'lodash/fp';
import * as iconComponents from '@sumup/icons';
import { icons } from '@sumup/icons/manifest.json';

import {
theme as themes,
Heading,
Text,
InlineElements,
Label,
SearchInput,
Select
} from '../../src';

function group(key, collection) {
const grouped = groupBy(key, collection);
return entries(grouped).map(([name, items]) => ({ [key]: name, items }));
}

function getComponentName(name) {
// Split on non-word characters
const words = name.split(/[^a-z0-9]/i);
// Uppercase the first letter and lowercase the rest
const pascalCased = words.map(
part => part.charAt(0).toUpperCase() + part.substr(1).toLowerCase()
);
return pascalCased.join('');
}

const Filters = styled(InlineElements)`
margin-top: ${p => p.theme.spacings.tera};
margin-bottom: ${p => p.theme.spacings.peta};
`;

const Category = styled.section`
margin-bottom: ${p => p.theme.spacings.tera};
`;

const List = styled.div`
display: flex;
flex-wrap: wrap;
`;

const Wrapper = styled.div`
width: 7.5rem;
text-align: center;
margin-top: ${p => p.theme.spacings.giga};
margin-bottom: ${p => p.theme.spacings.giga};
`;

const Size = styled.p`
color: ${p => p.theme.colors.n700};
font-style: italic;
`;

const iconStyles = color => theme => css`
height: 3rem;
width: auto;
max-width: 6rem;
color: ${theme.colors[color]};
background-color: ${color === 'white'
? theme.colors.n900
: theme.colors.bodyBg};
`;

const Icons = () => {
const [search, setSearch] = useState('');
const [size, setSize] = useState('all');
const [color, setColor] = useState('n900');

const handleSearch = event => {
setSearch(event.target.value);
};

const handleSizeChange = event => {
setSize(event.target.value);
};

const handleColorChange = event => {
setColor(event.target.value);
};

const sizeOptions = [
{ label: 'All sizes', value: 'all' },
{ label: 'Small', value: 'small' },
{ label: 'Large', value: 'large' }
];

const colorOptions = [
{ label: 'Dark gray', value: 'n900' },
{ label: 'Gray', value: 'n500' },
{ label: 'White', value: 'white' },
{ label: 'Primary', value: 'p500' },
{ label: 'Success', value: 'success' },
{ label: 'Warning', value: 'warning' },
{ label: 'Danger', value: 'danger' }
];

const activeIcons = icons.filter(
icon =>
includes(search, icon.name) && (size === 'all' || size === icon.size)
);

return (
<ThemeProvider theme={themes.circuit}>
<Filters>
<Label htmlFor="search-icon">
Filter icons by name
<SearchInput
id="search-icon"
placeholder="Search..."
value={search}
onChange={handleSearch}
/>
</Label>

<Label htmlFor="select-size">
Select icon size
<Select
id="select-size"
options={sizeOptions}
value={size}
onChange={handleSizeChange}
/>
</Label>

<Label htmlFor="select-color">
Select icon color
<Select
id="select-color"
options={colorOptions}
value={color}
onChange={handleColorChange}
/>
</Label>
</Filters>

{isEmpty(activeIcons) ? (
<Text>No icons found</Text>
) : (
group('category', activeIcons).map(({ category, items }) => (
<Category key={category}>
<Heading as="h3" size={Heading.GIGA}>
{category}
</Heading>
<List>
{sortBy('name', items).map(icon => {
const id = `${icon.name}-${icon.size}`;
const componentName = getComponentName(icon.name);
const Icon = iconComponents[componentName];
return (
<Wrapper key={id}>
<Icon id={id} size={icon.size} css={iconStyles(color)} />
<Label htmlFor="id">
{icon.name}
{size === 'all' && <Size>{icon.size}</Size>}
</Label>
</Wrapper>
);
})}
</List>
</Category>
))
)}
</ThemeProvider>
);
};

export default Icons;
5 changes: 5 additions & 0 deletions .storybook/components/Teaser.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ import { ThemeProvider } from 'emotion-theming';

import { theme as themes, Heading, Text, Card } from '../../src';

// HACK: This prevents the cards from awkwardly wrapping if one of them
// only has one line of text.
const CARD_HEIGHT = '185px';

const Wrapper = styled(Card)(
({ theme }) => css`
width: 100%;
Expand All @@ -29,6 +33,7 @@ const Wrapper = styled(Card)(
${theme.mq.mega} {
width: calc(50% - ${theme.spacings.giga});
margin-right: ${theme.spacings.giga};
min-height: ${CARD_HEIGHT};
}
`
);
Expand Down
1 change: 1 addition & 0 deletions .storybook/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export { default as MediaQueriesTable } from './MediaQueriesTable';
export { default as BorderWidth } from './BorderWidth';
export { default as BorderRadius } from './BorderRadius';
export { default as IconSize } from './IconSize';
export { default as Icons } from './Icons';
export { Grid, Row, Col } from './Grid';
export { default as Intro } from './Intro';
export { default as Teaser } from './Teaser';
Expand Down
2 changes: 1 addition & 1 deletion .storybook/manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { theme, components } from './util/theme';
addons.setConfig({
theme,
isFullscreen: false,
showPanel: false,
showPanel: true,
panelPosition: 'bottom',
isToolshown: true
});
9 changes: 8 additions & 1 deletion .storybook/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,14 @@ const SORT_ORDER = {
'Contributing',
'Code of Conduct'
],
Advanced: ['Static CSS', 'Base Components', 'Theme', 'Grid', 'Fonts'],
Advanced: [
'Static CSS',
'Base Components',
'Theme',
'Grid',
'Icons',
'Fonts'
],
Typography: ['Heading', 'SubHeading', 'Text'],
Layout: [],
Forms: [],
Expand Down
1 change: 0 additions & 1 deletion .babelrc → babel.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"plugins": [
"@babel/plugin-proposal-class-properties",
"lodash",
"inline-react-svg",
"dev-expression",
"react-docgen"
],
Expand Down
4 changes: 2 additions & 2 deletions docs/advanced/grid.story.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Meta, Preview, Grid, Row, Col } from '../../.storybook/components';
The grid provided by Circuit UI is a float-based grid. We use
this grid in applications where we need to support older browsers, such as Android and iOS webviews.

The [static CSS](Advanced|Static-CSS) does not include a grid system.
The [static CSS](Advanced/Static-CSS) does not include a grid system.

## Static columns

Expand All @@ -34,7 +34,7 @@ scenario, you can use the normal `span` attribute of the grid.

## Responsive columns

You can use the following [breakpoints](Advanced|Theme) to define the
You can use the following [breakpoints](Advanced/Theme) to define the
responsive behavior of your grid:

- `untilKilo`
Expand Down
15 changes: 15 additions & 0 deletions docs/advanced/icons.story.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Meta, Icons } from '../../.storybook/components';

<Meta title="Advanced/Icons" />

# Icons

The icons used throughout Circuit UI come from [SumUp's icon library](https://github.com/sumup-oss/icons). The [`@sumup/icons`](https://www.npmjs.com/package/@sumup/icons) package is a required peer dependency of [`@sumup/circuit-ui`](https://www.npmjs.com/package/@sumup/circuit-ui). You can install the package by running the following command in your project:

```bash
yarn add @sumup/icons
# Or if you prefer npm:
npm install @sumup/icons
```

<Icons />
8 changes: 4 additions & 4 deletions docs/advanced/theme.story.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ theme.borderWidth.[kilo|mega]
theme.typography.[headings|subHeadings|text].<SIZE_NAME>.[fontSize|lineHeight]
```

Avoid using `theme.typography` directly in your styles, rather use the specialized components [`Heading`](Typography|Heading/Base), [`SubHeading`](Typography|SubHeading/Base), and [`Text`](Typography|Text/Base).
Avoid using `theme.typography` directly in your styles, rather use the specialized components [`Heading`](Typography/Heading/Base), [`SubHeading`](Typography/SubHeading/Base), and [`Text`](Typography/Text/Base).

#### Headings

Expand Down Expand Up @@ -230,7 +230,7 @@ Avoid using `theme.typography` directly in your styles, rather use the specializ
theme.fontStack.[default|mono]
```

Refer to the [Fonts](Advanced|Fonts) documentation to learn how to define and load custom fonts in a performant way.
Refer to the [Fonts](Advanced/Fonts) documentation to learn how to define and load custom fonts in a performant way.

### Font weight

Expand All @@ -254,9 +254,9 @@ theme.grid.<BREAKPOINT>.[priority|breakpoint|cols|maxWidth|gutter]
The grid provided by Circuit UI is a float-based grid. We use
this grid in applications where we need to support older browsers, such as Android and iOS webviews.

The [static CSS](Advanced|Static-CSS) does not include a grid system.
The [static CSS](Advanced/Static-CSS) does not include a grid system.

Refer to the [grid](Advanced|Grid) documentation for an overview of the grid system.
Refer to the [grid](Advanced/Grid) documentation for an overview of the grid system.

### Breakpoints and media queries

Expand Down
2 changes: 1 addition & 1 deletion docs/introduction/contributing.story.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { Meta, Intro, Image } from '../../.storybook/components';
or become a core contributor. Here's how.
</Intro>

**In the interest of fostering an open and welcoming environment, we expect all participants to read and adhere to our [Code of Conduct](Introduction|Code-of-Conduct).**
**In the interest of fostering an open and welcoming environment, we expect all participants to read and adhere to our [Code of Conduct](Introduction/Code-of-Conduct).**

## Filing an issue

Expand Down
2 changes: 1 addition & 1 deletion docs/introduction/getting-started.story.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,4 @@ const App = () => (
export default App;
```

Refer to the [Theme documentation](Advanced|Theme) to learn how to use and customize the theme.
Refer to the [Theme documentation](Advanced/Theme) to learn how to use and customize the theme.
8 changes: 4 additions & 4 deletions docs/introduction/welcome.story.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -29,31 +29,31 @@ import {

Set up a new app with Circuit UI or add it to an existing project.

[Get started](Introduction|Getting-started)
[Get started](Introduction/Getting-started)

</Teaser>

<Teaser title="Design principles">

Discover the guiding principles behind Circuit UI's design.

[Read design guidelines](Introduction|Design-Principles)
[Read design guidelines](Introduction/Design-Principles)

</Teaser>

<Teaser title="Theming">

Learn about our foundations such as colors, spacing, and typography.

[Browse theme reference](Advanced|Theme)
[Browse theme reference](Advanced/Theme)

</Teaser>

<Teaser title="Contributing">

File a bug report, suggest a change, or open a pull request.

[Contribute](Introduction|Contributing)
[Contribute](Introduction/Contributing)

</Teaser>

Expand Down
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module.exports = {
collectCoverageFrom: [
'src/@(components|util|styles)/**/*.{ts,tsx,js,jsx}',
'!src/@(components|util|styles)/**/index.{ts,tsx,js,jsx}',
'!src/@(components|util|styles)/**/*.story.{jts,tsx,s,jsx}',
'!src/@(components|util|styles)/**/*.story.{ts,tsx,js,jsx}',
'!src/@(components|util|styles)/**/*.docs.mdx',
'!**/node_modules/**'
],
Expand Down
Loading