You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+43Lines changed: 43 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -76,6 +76,49 @@ export default () => (
76
76
77
77
This will set the `color`, `font-family`, and `line-height` CSS properties to the same ones used in [primer-base](https://github.com/primer/primer/blob/master/modules/primer-base/lib/base.scss#L15).
78
78
79
+
#### Theming
80
+
81
+
Components are styled using Primer's [theme](https://github.com/primer/components/blob/master/src/theme.js) by default, but you can provide your own theme by using [styled-component's][styled-components]`<ThemeProvider>`. If you'd like to fully replace the Primer [theme](https://github.com/primer/components/blob/master/src/theme.js) with your custom theme, pass your theme to the `<ThemeProvider>` in the root of your application like so:
82
+
83
+
```jsx
84
+
import {ThemeProvider} from'styled-components'
85
+
86
+
consttheme= { ... }
87
+
88
+
constApp= (props) => {
89
+
return (
90
+
<div>
91
+
<ThemeProvider theme={theme}>
92
+
<div>your app here</div>
93
+
</ThemeProvider>
94
+
</div>
95
+
)
96
+
}
97
+
98
+
```
99
+
100
+
If you'd like to merge the Primer theme with your theme, you can do so importing the Primer theme and merging using Object.assign:
101
+
102
+
```jsx
103
+
import {ThemeProvider} from'styled-components'
104
+
import {theme} from'@primer/components'
105
+
106
+
constcustomTheme= { ... }
107
+
108
+
109
+
constApp= (props) => {
110
+
return (
111
+
<div>
112
+
<ThemeProvider theme={Object.assign({}, theme, customTheme)}>// matching keys in customTheme will override keys in the Primer theme
113
+
<div>your app here</div>
114
+
</ThemeProvider>
115
+
</div>
116
+
)
117
+
}
118
+
```
119
+
120
+
*Note that using `Object.assign` will only create a shallow merge. This means that if both themes have a `color` object, the _entire_`color` object will be replaced with the new `color` object, instead of only replacing duplicate values from the original theme's color object.
121
+
79
122
#### Static CSS rendering
80
123
81
124
If you're rendering React components both server-side _and_ client-side, we suggest following [styled-component's server-side rendering instructions](https://www.styled-components.com/docs/advanced#server-side-rendering) to avoid the flash of unstyled content for server-rendered components. This repo's [documentation template component](https://github.com/primer/components/blob/master/pages/_document.js) demonstrates how to do this in [Next.js].
Copy file name to clipboardExpand all lines: contributing.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -63,7 +63,7 @@ Default values for system props can be set in `Component.defaultProps`.
63
63
64
64
Prop Types from system props such as `COMMON` or `TYPOGRAPHY` as well as styled-system functions can be spread in the component's prop types declaration (see example below).
65
65
66
-
⚠️ **Make sure to always set the default `theme` prop to our theme! This allows consumers of our components to access our theme values without a ThemeProvider.**
66
+
⚠️ **Make sure to always set the default `theme` prop to our [theme](https://github.com/primer/components/blob/master/src/theme.js)! This allows consumers of our components to access our theme values without a ThemeProvider.**
Copy file name to clipboardExpand all lines: pages/components/docs/Dropdown.md
+23-8Lines changed: 23 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,26 +3,41 @@
3
3
4
4
The Dropdown component is a lightweight context menu for housing navigation and actions.
5
5
6
+
Dropdown.Button is used to trigger opening and closing the dropdown.
7
+
8
+
Dropdown.Menu wraps your menu content. Be sure to pass a `direction` prop to this component to position the menu in relation to the Dropdown.Button.
9
+
6
10
## Default example
7
11
```.jsx
8
12
<Dropdown scheme="primary" minWidth="5em">
9
-
<Box role="list">
10
-
<Box role="listitem">Item 1</Box>
11
-
<Box role="listitem">Item 2</Box>
12
-
<Box role="listitem">Item 3</Box>
13
-
</Box>
13
+
<Dropdown.Button>Dropdown </Dropdown.Button>
14
+
<Dropdown.Menu direction='sw'>
15
+
<Dropdown.Item>Item 1</Dropdown.Item>
16
+
<Dropdown.Item>Item 2</Dropdown.Item>
17
+
<Dropdown.Item>Item 3</Dropdown.Item>
18
+
</Dropdown.Menu>
14
19
</Dropdown>
15
20
```
16
21
17
22
## System props
18
23
19
-
Dropdown components get `COMMON` system props. Read our [System Props](/components/docs/system-props) doc page for a full list of available props.
24
+
Dropdown, Dropdown.Menu, Dropdown.Button, and Dropdown.Item all get `COMMON` system props. Read our [System Props](/components/docs/system-props) doc page for a full list of available props.
20
25
21
26
## Component props
22
27
28
+
#### Dropdown.Menu
23
29
| Name | Type | Default | Description |
24
30
| :- | :- | :-: | :- |
25
-
| scheme | String || Button scheme used to style the component, can be one of `danger`, `outline` or `primary`|
26
-
| title | String | | Optional prop to set the text in the Dropdown button
31
+
| direction | String | 'sw' | Sets the direction of the dropdown menu. |
0 commit comments