5.19.1 • Published 9 days ago

@purple/phoenix-components v5.19.1

Weekly downloads
765
License
MIT
Repository
github
Last release
9 days ago

Phoenix components

This project is using Percy.io for visual regression testing.

Our aim is to build a simple React components library using styled-components and TypeScript.

3rd party libraries

Phoenix Components takes advantage of some 3rd party libraries to create consistently styled components

  • @tippyjs/react - dropdown and positioning engine for the Dropdown component
  • countries-and-timezones - list of timezones for the TimezonePicker component
  • is-mobile - detecting mobile device for the Select component
  • nanoid - unique string ID generator for Checkbox and Radio components
  • noUiSlider - complete solution for the Slider (and Range) component
  • react-day-picker - date picker for DatePicker and DateRangePicker components
  • react-dropzone - drag'n'drop support for the FileUpload component
  • react-inlinesvg - Inline loading of SVG files (to support hover effects) across all components using icons
  • react-pdf - PDF files preview for the FileUpload component
  • react-select - complete solution for the Select component
  • react-tabs - complete solution for the Tabs component and its subcomponents (TabList, Tab and TabPanel)

Demo & Documentation

Phoenix Components Storybook

Deployment process

Before merging to master run npm run release:feature, this will create a new version tag. After that you can merge your branch to master and from there you can run npm run release:publish.

Install

npm i @purple/phoenix-components

Usage with default (Axiory) design tokens

  1. Phoenix components use by default Mulish font with weights 400 and 600. If you want to use this default font, please add it to your project, using for example Google Fonts.

    <link rel="preconnect" href="https://fonts.gstatic.com">
    <link href="https://fonts.googleapis.com/css2?family=Mulish:wght@400;600&display=swap" rel="stylesheet">
  2. Import Theme from Phoenix Components and wrap the app in <ThemeProvider> from styled-components providing the Theme object. If your repository already contains custom styled-components theme, merge both themes together. Also, import <GlobalStyles> component which provides styles such as default font and sizes, and include it once in your project.

    import merge from 'lodash/merge'
    import { ThemeProvider } from 'styled-components'
    import { GlobalStyles, Theme as PhoenixTheme } from '@purple/phoenix-components'
    import { Theme } from './CustomAppTheme'
    ...
    
    function App() {
    	return (
    		<ThemeProvider theme={merge(PhoenixTheme, Theme)}>
    			<GlobalStyles />
    			{ ... your app ... }
    		</ThemeProvider>
    	)
    }

    You can optionally include dir key in the theme with values either 'ltr' or 'rtl'. This is not required but it will slightly optimize CSS generated to support right-to-left layouts, resulting in smaller footprint.

    ...
    <ThemeProvider theme={merge({ dir: 'rtl' }, Theme)}>
    ...
  3. Import components that you need and use them according to the docs.

    import { TextInput } from '@purple/phoenix-components'

Components customization

You can extend the components with styled-components. For example:

import styled from 'styled-components'
import { TextInput } from '@purple/phoenix-components'

const StyledInput = styled(TextInput)`
	// css overrides here
`

Custom design tokens

Since version 5, Phoenix components use design tokens for styling. If you want to change appearance of the components you need to provide ThemeProvider with a custom set of tokens (JSON file).

Previously (in v4), components were styled using object $pc within the theme file. This object is deprecated and will be removed in version 6.

Default MyAxiory tokens bundled with Phoenix components come from this repository https://github.com/purple-technology/my-axiory-tokens. These tokens originate from designers, specifically from Figma plugin called Tokens Studio. For your own project, you need to be given an access to a similar repo with custom design tokens.

Tokens in the repo come as a generic JSON file (or multiple files) that can be used on different platforms - web, mobile (iOS, Android). But in order to use them on each platform they need to be transformed accordingly for better usability. For this transformation, a tool called style-dictionary is used. Very basic config file could look like this (style-dictionary.config.json):

{
	"source": [
		"my-axiory-tokens/tokens/global.json"
	],
	"platforms": {
		"js": {
			"transformGroup": "js",
			"buildPath": "src/tokens/",
			"files": [
				{
					"destination": "tokens.json",
					"format": "json/nested"
				}
			]
		}
  }
}

Build process

  1. Pull repo with custom tokens, for example:

    git -C my-axiory-tokens pull || git clone https://github.com/purple-technology/my-axiory-tokens.git
  2. Run style-dictionary build which takes by default style-dictionary.config.json file placed in root of the project.

  3. Merge default Phoenix theme with your custom generated tokens JSON file and provide it to ThemeProvider component. Note: tokens reside within the theme object as a key tokens!

    import customTokens from './customTokens.json'
    
    (...)
    
    <ThemeProvider theme={merge(PhoenixTheme, { tokens: customTokens })}>

🔼 Migration guide from v4 to v5

Phoenix Components ver. 5 transitioned to using Design tokens. This change affected namings of several entities.

Sizes

Sizes of the components have been updated to be more consistent with other sizing and spacing units.

Previous sizeCurrent size
tinyxs
smallsm
mediummd
largelg

These changes affect components Button, ButtonGroup, DateInput, Heading, LinkButton, List, Modal, MultiSelect, Pagination, Paragraph, Tag and Text.

What to do?

Find all instances of size="tiny" and replace with size="xs". Similarly for other sizes. Don't forget that a value can be written also for example size={'tiny'} or that value can be calculated so you won't be able to look these instances so easily.

Also sizing types have been renamed.

Previous size typeCurrent size type
ComponentSizeSizing
ComponentSizeSmallMediumSizingSmMd
ComponentSizeMediumLargeSizingMdLg
ComponentSizeSmallMediumLargeSizingSmMdLg

What to do?

Replace all previous size types with the new ones.

Colors

Text colors were renamed

Previous colorCurrent color
darkestprimary
darksecondary
lighttertiary
lightestquaternary

These changes affect components Heading, Paragraph and Text.

For the ColorTheme enum and colorTheme props, the color primary has been renamed to color brand. Other colors (success, warning, error, info, neutral) remain the same.

What to do?

  • Search for all colorTheme="primary" and replace with colorTheme="brand"
  • Search for all color="darkest" and replace with color="primary". Same for dark, light and lightest.

Spacings

Spacings were also updated to be more consistent with other units. However, these changes are backwards compatible. Old values have been deprecated and will be removed in the next major version.

Previous valueCurrent value
xxxs3xs
xxs2xs
xsxs
ssm
mmd
llg
xlxl
xxl2xl
xxxl3xl

What to do?

Since these changes are backwards-compatible, you don't have to do anything right now. But from now on, use the new values. Also, only new values will be hinting in your editor.

Button and Link Button

Both components have now a new style available - outline. This style can be enabled by the prop named outline.

Minimal style is now available in all color themes. Default style for minimal is now brand, instead of neutral.

What to do?

If you want to keep the same styling, add colorTheme="neutral" to Buttons with minimal prop.

Tag

Previously, this component had only a single style. Currently, there are 3 styles available that correspond with the styles of the button - primary, secondary and outline. Default style is now primary. Previous style is currently secondary and must be explicitly enabled by the prop secondary.

What to do?

Search for all instances of Tag component and add secondary prop.

Heading, Paragraph and Text

Prop colorTheme has been removed and there's only color prop now excepting all text colors (primary, secondary, tertiary, quaternary), color theme colors (brand, success, warning, error, info, neutral) and any valid CSS value.

Instead of 3 sizes (small, medium, large), these components now include 4 sizes - xs, sm, md, lg. For Text and Paragraph components, default value is now sm. Since there's one more size, original size small is now xs.

What to do?

  • Search all instances of Text, Paragraph and Heading and replace colorTheme with color.
  • Replace size="small" with size="xs". (If you already replaced sizing with new sizes, you have to search for size="sm".)

Also, Paragraph component now has a new prop lineHeight which accepts standard sizing values xs, sm, md and lg or any other valid CSS value. Default value is md.

List and ListItem

Prop colorTheme has been removed and there's only color prop now excepting all text colors (primary, secondary, tertiary, quaternary), color theme colors (brand, success, warning, error, info, neutral) and any valid CSS value. Also, color prop now affects only text. To change color of the bullet, use bulletColor which accepts the same values.

What to do?

  • Search all instances of List and ListItem and replace colorTheme with bulletColor.
  • Search for all bulletColor props and change darkest to primary, dark to secondary etc. (see the section Colors)

Icon

Props colorTheme and light removed and replaced with a simple color prop. This prop behaves similarly like prop color in Heading/Text/Paragraph components, ie. excepting all text colors (primary, secondary, tertiary, quaternary), color theme colors (brand, success, warning, error, info, neutral) and any valid CSS value.

Also, filled icons ending with -primary are now named as -brand, so instead of icon="smartphone-primary", it's now icon="smartphone-brand" etc.

What to do?

  • Search for all instances of Icon component and if there's a light prop, then just replace it with color="white"
  • Search for all instances of Icon component and replace all colorTheme props with color (Note: If you haven't already done it before, replace values primary with brand - see the section Colors)
  • Search for all used filled brand icons. These icons were ending with -primary. You have to replace all -primary at the end with -brand

Spacer

This component was marked as deprecated in v4 and was removed in v5. Use Box component instead.

What to do?

  • Search for all instances of Spacer component and replace them with Box component. If there's a prop w or h used, use some kind of margin or padding prop instead (mt, pl, pr etc.). You can also use width or height props but these do not support Spacing values (xs, sm, md etc.).

🔼 Migration guide from v3 to v4

In prop tables, all removed properties are listed with notes how to update the component.

Alert

Renamed to Notice.

PropertyNotes
textUse children instead.
centerTextToo specific prop. Centered text in a notice component is discouraged. If needed, however, it can be done manually through child element with custom styling.
typeUse colorTheme instead.
contentColorUse colorTheme instead.
backgroundColorUse colorTheme instead.
titleUse children instead.

Button

PropertyNotes
colorUse colorTheme instead.
backgroundUse colorTheme instead.

CheckBox

Renamed to Checkbox (B lowercase).

PropertyNotes
colorUse colorTheme instead.

DateInput

PropertyNotes
labelRemoved. If needed, use standalone component Label.

FileUpload

PropertyNotes
colorUse colorTheme instead.

SelectBox

Renamed to Select.

PropertyNotes
autoCompleteRemove. Select does not support autoComplete prop and it was not used in the v3 anyway.
descriptionDescription is not part of this component anymore. If any description above the text input is needed, use component Text or Paragraph.
backgroundRemove. Should not be desired. We strive for unified design.
borderRemove. Should not be desired. We strive for unified design.
rowHeightRemove without replacement.

SelectPicker

PropertyNotes
borderColorUse colorTheme instead.
labelRemoved. If needed, use standalone component Label.

TextArea

PropertyNotes
typeRemove without replacement. textarea does not have an attribute type.
withBorderRemove without replacement. Should not be desired. We strive for unified design.

TextInput

PropertyNotes
descriptionDescription is not part of this component anymore. If any description above the text input is needed, create a custom element with custom styling.
descriptionFontSizeThe same applies as for description prop.
backgroundRemove without replacement. Background color should not be modified.
disableErrorTextIf we don't want to display error text but want to mark the input as errored, we set the property error to true (instead of string).
focusColorRemove without replacement. Focus color should not be modified.
5.19.1

9 days ago

5.18.0

20 days ago

5.19.0

20 days ago

5.17.0

1 month ago

5.16.0

4 months ago

5.15.1

4 months ago

5.15.0

5 months ago

5.13.2-beta.0

7 months ago

5.11.0

9 months ago

5.12.0

8 months ago

5.14.1-beta.0

6 months ago

5.9.0

9 months ago

5.13.1

7 months ago

5.13.0

8 months ago

5.14.1

6 months ago

5.14.0

7 months ago

5.10.0

9 months ago

5.11.0-beta.1

9 months ago

5.11.0-beta.0

9 months ago

5.8.0

11 months ago

5.6.0

1 year ago

5.7.0

11 months ago

5.3.1

1 year ago

5.3.0

1 year ago

5.0.0-beta.4

1 year ago

5.0.0-beta.3

1 year ago

5.4.0

1 year ago

5.0.0

1 year ago

5.5.1

1 year ago

5.5.0

1 year ago

5.1.0

1 year ago

5.2.0

1 year ago

5.0.0-beta.2

1 year ago

5.0.0-beta.0

1 year ago

5.0.0-beta.1

1 year ago

5.0.0-alpha.7

1 year ago

5.0.0-alpha.6

1 year ago

5.0.0-alpha.5

1 year ago

5.0.0-alpha.4

1 year ago

5.0.0-alpha.3

1 year ago

5.0.0-alpha.2

1 year ago

5.0.0-alpha.1

1 year ago

5.0.0-alpha.0

1 year ago

4.36.0

1 year ago

4.35.2

1 year ago

4.33.0

2 years ago

4.35.1

1 year ago

4.35.0

1 year ago

4.34.0

1 year ago

4.32.0

2 years ago

4.31.0

2 years ago

4.29.0

2 years ago

4.28.0

2 years ago

4.28.1

2 years ago

4.27.1

2 years ago

4.27.2

2 years ago

4.30.0

2 years ago

4.27.0

2 years ago

4.25.0

2 years ago

4.24.1

2 years ago

4.24.2

2 years ago

4.24.0

2 years ago

4.23.4

2 years ago

4.23.5

2 years ago

4.21.0

2 years ago

4.20.2

2 years ago

4.20.0

2 years ago

4.20.1

2 years ago

4.23.0

2 years ago

4.23.1

2 years ago

4.23.2

2 years ago

4.22.0

2 years ago

4.22.1

2 years ago

4.22.2

2 years ago

4.22.3

2 years ago

4.23.3

2 years ago

4.18.0

2 years ago

4.19.0

2 years ago

4.19.1

2 years ago

4.17.0

2 years ago

4.17.1

2 years ago

4.14.0

3 years ago

4.16.0

3 years ago

4.15.0

3 years ago

4.13.0

3 years ago

4.12.0

3 years ago

4.12.1

3 years ago

4.11.0

3 years ago

4.9.0

3 years ago

4.10.0

3 years ago

4.8.1

3 years ago

4.7.2

3 years ago

4.7.0

3 years ago

4.7.1

3 years ago

4.6.1

3 years ago

4.6.0

3 years ago

4.5.0

3 years ago

4.4.1

3 years ago

4.4.0

3 years ago

4.3.1

3 years ago

4.3.0

3 years ago

4.2.0

3 years ago

4.1.0

3 years ago

4.0.0

3 years ago

3.0.2

3 years ago

3.0.1

3 years ago

3.0.0

3 years ago

2.10.0

3 years ago

2.9.0

3 years ago

2.8.5

3 years ago

2.8.3

3 years ago

2.8.4

3 years ago

2.8.1

3 years ago

2.8.0

3 years ago

2.8.2

3 years ago

2.7.1

3 years ago

2.7.0

3 years ago

2.6.2

3 years ago

2.6.1

3 years ago

2.5.3

3 years ago

2.5.2

3 years ago

2.5.0

3 years ago

2.5.1

3 years ago

2.4.7

4 years ago

2.4.6

4 years ago

2.4.5

4 years ago

2.4.4

4 years ago

2.4.1

4 years ago

2.4.0

4 years ago

2.3.0

4 years ago

2.2.0

4 years ago

2.1.3

4 years ago

2.1.2

4 years ago

2.1.1

4 years ago

2.1.0

4 years ago

2.0.0

4 years ago

1.0.13

4 years ago

1.0.12

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

0.0.41

4 years ago

0.0.40

4 years ago

0.0.39

4 years ago

0.0.37

4 years ago

0.0.38

4 years ago

0.0.36

4 years ago

0.0.35

4 years ago

0.0.34

4 years ago

0.0.33

4 years ago

0.0.30

4 years ago

0.0.31

4 years ago

0.0.32

4 years ago

0.0.29

4 years ago

0.0.28

4 years ago

0.0.26

4 years ago

0.0.27

4 years ago

0.0.25

4 years ago

0.0.24

4 years ago

0.0.23

4 years ago

0.0.22

4 years ago

0.0.21

4 years ago

0.0.20

4 years ago

0.0.19

4 years ago

0.0.18

4 years ago

0.0.17

4 years ago

0.0.16

4 years ago

0.0.14

4 years ago

0.0.15

4 years ago

0.0.13

4 years ago

0.0.12

4 years ago

0.0.11

5 years ago

0.0.10

5 years ago

0.0.9

5 years ago

0.0.8

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago