@purple/phoenix-components 5.11.0 → 5.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +72 -39
- package/dist/bundle.cjs.js +1 -1
- package/dist/bundle.cjs.js.map +1 -1
- package/dist/bundle.esm.js +1 -15
- package/dist/bundle.esm.js.map +1 -1
- package/dist/bundle.umd.js +1 -1
- package/dist/bundle.umd.js.map +1 -1
- package/dist/index.d.ts +32 -1
- package/package.json +7 -4
package/README.md
CHANGED
|
@@ -30,49 +30,49 @@ Before merging to master run `npm run release:feature`, this will create a new v
|
|
|
30
30
|
|
|
31
31
|
## Install
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
npm i @purple/phoenix-components
|
|
34
34
|
|
|
35
35
|
## Usage with default (Axiory) design tokens
|
|
36
36
|
|
|
37
37
|
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.
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
```html
|
|
40
|
+
<link rel="preconnect" href="https://fonts.gstatic.com">
|
|
41
|
+
<link href="https://fonts.googleapis.com/css2?family=Mulish:wght@400;600&display=swap" rel="stylesheet">
|
|
42
|
+
```
|
|
43
43
|
|
|
44
44
|
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.
|
|
45
45
|
|
|
46
|
-
```typescript
|
|
47
|
-
import merge from 'lodash/merge'
|
|
48
|
-
import { ThemeProvider } from 'styled-components'
|
|
49
|
-
import { GlobalStyles, Theme as PhoenixTheme } from '@purple/phoenix-components'
|
|
50
|
-
import { Theme } from './CustomAppTheme'
|
|
51
|
-
...
|
|
52
|
-
|
|
53
|
-
function App() {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
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.
|
|
64
|
-
|
|
65
|
-
```typescript
|
|
66
|
-
...
|
|
67
|
-
<ThemeProvider theme={merge({ dir: 'rtl' }, Theme)}>
|
|
68
|
-
...
|
|
69
|
-
```
|
|
46
|
+
```typescript
|
|
47
|
+
import merge from 'lodash/merge'
|
|
48
|
+
import { ThemeProvider } from 'styled-components'
|
|
49
|
+
import { GlobalStyles, Theme as PhoenixTheme } from '@purple/phoenix-components'
|
|
50
|
+
import { Theme } from './CustomAppTheme'
|
|
51
|
+
...
|
|
52
|
+
|
|
53
|
+
function App() {
|
|
54
|
+
return (
|
|
55
|
+
<ThemeProvider theme={merge(PhoenixTheme, Theme)}>
|
|
56
|
+
<GlobalStyles />
|
|
57
|
+
{ ... your app ... }
|
|
58
|
+
</ThemeProvider>
|
|
59
|
+
)
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
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.
|
|
64
|
+
|
|
65
|
+
```typescript
|
|
66
|
+
...
|
|
67
|
+
<ThemeProvider theme={merge({ dir: 'rtl' }, Theme)}>
|
|
68
|
+
...
|
|
69
|
+
```
|
|
70
70
|
|
|
71
71
|
3. Import components that you need and use them according to [the docs](https://purple-technology.github.io/phoenix-components).
|
|
72
72
|
|
|
73
|
-
```typescript
|
|
74
|
-
import { TextInput } from '@purple/phoenix-components'
|
|
75
|
-
```
|
|
73
|
+
```typescript
|
|
74
|
+
import { TextInput } from '@purple/phoenix-components'
|
|
75
|
+
```
|
|
76
76
|
|
|
77
77
|
## Components customization
|
|
78
78
|
|
|
@@ -90,17 +90,50 @@ const StyledInput = styled(TextInput)`
|
|
|
90
90
|
|
|
91
91
|
## Custom design tokens
|
|
92
92
|
|
|
93
|
-
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
|
|
93
|
+
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).
|
|
94
|
+
|
|
95
|
+
> Previously (in v4), components were styled using object `$pc` within the theme file. This object is deprecated and will be removed in version 6.
|
|
96
|
+
|
|
97
|
+
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.
|
|
98
|
+
|
|
99
|
+
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`](https://amzn.github.io/style-dictionary/#/) is used. Very basic config file could look like this (`style-dictionary.config.json`):
|
|
100
|
+
|
|
101
|
+
```json
|
|
102
|
+
{
|
|
103
|
+
"source": [
|
|
104
|
+
"my-axiory-tokens/tokens/global.json"
|
|
105
|
+
],
|
|
106
|
+
"platforms": {
|
|
107
|
+
"js": {
|
|
108
|
+
"transformGroup": "js",
|
|
109
|
+
"buildPath": "src/tokens/",
|
|
110
|
+
"files": [
|
|
111
|
+
{
|
|
112
|
+
"destination": "tokens.json",
|
|
113
|
+
"format": "json/nested"
|
|
114
|
+
}
|
|
115
|
+
]
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
```
|
|
94
120
|
|
|
95
|
-
|
|
96
|
-
import customTokens from './customTokens.json'
|
|
121
|
+
### Build process
|
|
97
122
|
|
|
98
|
-
|
|
123
|
+
1. Pull repo with custom tokens, for example:
|
|
99
124
|
|
|
100
|
-
|
|
101
|
-
|
|
125
|
+
git -C my-axiory-tokens pull || git clone https://github.com/purple-technology/my-axiory-tokens.git
|
|
126
|
+
|
|
127
|
+
2. Run `style-dictionary build` which takes by default `style-dictionary.config.json` file placed in root of the project.
|
|
128
|
+
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`!**
|
|
129
|
+
|
|
130
|
+
```typescript
|
|
131
|
+
import customTokens from './customTokens.json'
|
|
132
|
+
|
|
133
|
+
(...)
|
|
102
134
|
|
|
103
|
-
|
|
135
|
+
<ThemeProvider theme={merge(PhoenixTheme, { tokens: customTokens })}>
|
|
136
|
+
```
|
|
104
137
|
|
|
105
138
|
## 🔼 Migration guide from v4 to v5
|
|
106
139
|
|