Skip to content

Commit 5d49063

Browse files
committed
Merge remote-tracking branch 'origin/master' into feat-300-nnnnat-add-viewerInfo
2 parents 50b50b4 + fec9d70 commit 5d49063

File tree

66 files changed

+404
-332
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+404
-332
lines changed

docs/theming.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Theming
2+
3+
## Styling StarterKit and Material UI components
4+
5+
Most of the components in the starter kit are based on the [Material UI](https://material-ui.com) components. As such, they can usually be customized using the same methods as the base Material UI components.
6+
7+
### Changing theme variables
8+
9+
Variables for customizing the theme are located in the `[src/lib/theme/reactionTheme.js](https://github.com/reactioncommerce/reaction-next-starterkit/blob/master/src/lib/theme/reactionTheme.js) file. The [Material UI theme guide](https://material-ui.com/customization/themes/) has additional details on how to customize the theme.
10+
11+
For example, you can change the various colors used for the primary color, fonts used, layout dimensions and more. All of the [default theme variables from Material UI](https://material-ui.com/customization/default-theme/) are available to override as well as any additional variables added for the Starter Kit itself.
12+
13+
```js
14+
import { createMuiTheme } from "@material-ui/core/styles";
15+
16+
const theme = createMuiTheme({
17+
layout: {
18+
mainContentMaxWidth: "1440px",
19+
mainLoginMaxWidth: "1024px"
20+
},
21+
palette: {
22+
primary: {
23+
light: "#26B0F9",
24+
main: "#1999DD",
25+
dark: "#172F3C",
26+
contrastText: "#FFFFFF"
27+
},
28+
...
29+
```
30+
31+
### Applying global overrides
32+
33+
Styles for components can be overridden globally from the [src/lib/theme/reactionTheme.js](https://github.com/reactioncommerce/reaction-next-starterkit/blob/master/src/lib/theme/reactionTheme.js) file. **Before applying an override, consider updating the theme variables as it may provide you with better results.**
34+
35+
When using overrides you cannot add additional class names that aren't already present in the original component. You can add override existing CSS properties or add new CSS properties that may not exist in the original component's style.
36+
37+
Consult source code for that component you which to override for, both the style name used for overrides, as well as the class names that are available for customization.
38+
39+
40+
For more information on how to override styles please consult the [Material UI guide on overrides](https://material-ui.com/customization/overrides/).
41+
42+
#### Theme overrides example
43+
44+
To add custom overrides, simply add an `overrides` object to the theme. The `overrides` object contains a key which matches the component name with a prefix, and the value being an object with your overrides to apply to that component.
45+
46+
- Starter Kit components are prefixed with `Sk` in the theme. e.g. `SkHeader`.
47+
- Material UI components are prefixed with `Mui` in the theme. e.g. `MuiAppBar`.
48+
49+
**src/lib/theme/reactionTheme.js**
50+
51+
```js
52+
import { createMuiTheme } from "@material-ui/core/styles";
53+
54+
const theme = createMuiTheme({
55+
overrides: {
56+
// Override styles for the Starter kit header
57+
SkHeader: { // Name of the component
58+
appBar: { // Class name to override
59+
backgroundColor: "green" // Property to add or override
60+
}
61+
}
62+
},
63+
...
64+
```

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
},
3434
"dependencies": {
3535
"@material-ui/core": "^3.1.0",
36-
"@reactioncommerce/components": "0.38.0",
36+
"@reactioncommerce/components": "^0.38.1",
3737
"@reactioncommerce/components-context": "^1.0.0",
3838
"@segment/snippet": "^4.3.1",
3939
"apollo-cache-inmemory": "^1.1.11",

src/components/AccountDropdown/AccountDropdown.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const styles = (theme) => ({
1919
}
2020
});
2121

22-
@withStyles(styles)
22+
@withStyles(styles, { name: "SkAccountDropdown" })
2323
@inject("authStore")
2424
@observer
2525
class AccountDropdown extends Component {

src/components/Breadcrumbs/Breadcrumbs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const styles = (theme) => ({
2929
}
3030
});
3131

32-
@withStyles(styles)
32+
@withStyles(styles, { name: "SkBreadcrumbs" })
3333
class Breadcrumbs extends Component {
3434
static propTypes = {
3535
classes: PropTypes.object.isRequired,

src/components/Breadcrumbs/__snapshots__/Breadcrumbs.test.js.snap

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,25 @@
22

33
exports[`tagGrid secondlevel tag 1`] = `
44
<div
5-
className="Breadcrumbs-container-1"
5+
className="SkBreadcrumbs-container-1"
66
>
77
<a
8-
className="Link-anchor-4"
8+
className="SkLink-anchor-4"
99
href="/"
1010
onClick={[Function]}
1111
onKeyDown={[Function]}
1212
role="link"
1313
tabIndex={0}
1414
>
1515
<span
16-
className="Breadcrumbs-breadcrumbLink-2"
16+
className="SkBreadcrumbs-breadcrumbLink-2"
1717
>
1818
Home
1919
</span>
2020
</a>
2121
<svg
2222
aria-hidden="true"
23-
className="MuiSvgIcon-root-5 Breadcrumbs-breadcrumbIcon-3"
23+
className="MuiSvgIcon-root-5 SkBreadcrumbs-breadcrumbIcon-3"
2424
color={undefined}
2525
focusable="false"
2626
role="presentation"
@@ -31,22 +31,22 @@ exports[`tagGrid secondlevel tag 1`] = `
3131
/>
3232
</svg>
3333
<a
34-
className="Link-anchor-4"
34+
className="SkLink-anchor-4"
3535
href="/tag/tag-a"
3636
onClick={[Function]}
3737
onKeyDown={[Function]}
3838
role="link"
3939
tabIndex={0}
4040
>
4141
<span
42-
className="Breadcrumbs-breadcrumbLink-2"
42+
className="SkBreadcrumbs-breadcrumbLink-2"
4343
>
4444
Tag A
4545
</span>
4646
</a>
4747
<svg
4848
aria-hidden="true"
49-
className="MuiSvgIcon-root-5 Breadcrumbs-breadcrumbIcon-3"
49+
className="MuiSvgIcon-root-5 SkBreadcrumbs-breadcrumbIcon-3"
5050
color={undefined}
5151
focusable="false"
5252
role="presentation"
@@ -57,15 +57,15 @@ exports[`tagGrid secondlevel tag 1`] = `
5757
/>
5858
</svg>
5959
<a
60-
className="Link-anchor-4"
60+
className="SkLink-anchor-4"
6161
href="/tag/tag-a-1"
6262
onClick={[Function]}
6363
onKeyDown={[Function]}
6464
role="link"
6565
tabIndex={0}
6666
>
6767
<span
68-
className="Breadcrumbs-breadcrumbLink-2"
68+
className="SkBreadcrumbs-breadcrumbLink-2"
6969
>
7070
Tag A-1
7171
</span>
@@ -75,25 +75,25 @@ exports[`tagGrid secondlevel tag 1`] = `
7575

7676
exports[`tagGrid top level tag 1`] = `
7777
<div
78-
className="Breadcrumbs-container-1"
78+
className="SkBreadcrumbs-container-1"
7979
>
8080
<a
81-
className="Link-anchor-4"
81+
className="SkLink-anchor-4"
8282
href="/"
8383
onClick={[Function]}
8484
onKeyDown={[Function]}
8585
role="link"
8686
tabIndex={0}
8787
>
8888
<span
89-
className="Breadcrumbs-breadcrumbLink-2"
89+
className="SkBreadcrumbs-breadcrumbLink-2"
9090
>
9191
Home
9292
</span>
9393
</a>
9494
<svg
9595
aria-hidden="true"
96-
className="MuiSvgIcon-root-5 Breadcrumbs-breadcrumbIcon-3"
96+
className="MuiSvgIcon-root-5 SkBreadcrumbs-breadcrumbIcon-3"
9797
color={undefined}
9898
focusable="false"
9999
role="presentation"
@@ -104,15 +104,15 @@ exports[`tagGrid top level tag 1`] = `
104104
/>
105105
</svg>
106106
<a
107-
className="Link-anchor-4"
107+
className="SkLink-anchor-4"
108108
href="/tag/tag-a"
109109
onClick={[Function]}
110110
onKeyDown={[Function]}
111111
role="link"
112112
tabIndex={0}
113113
>
114114
<span
115-
className="Breadcrumbs-breadcrumbLink-2"
115+
className="SkBreadcrumbs-breadcrumbLink-2"
116116
>
117117
Tag A
118118
</span>

src/components/Cart/Cart.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const styles = () => ({
1010
}
1111
});
1212

13-
@withStyles(styles)
13+
@withStyles(styles, { name: "SkCart" })
1414
@inject("uiStore")
1515
@observer
1616
class Cart extends Component {

src/components/CartItems/CartItems.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const styles = (theme) => ({
1717
}
1818
});
1919

20-
@withStyles(styles)
20+
@withStyles(styles, { name: "SkCartItems" })
2121
class CartItems extends Component {
2222
static propTypes = {
2323
classes: PropTypes.object,

src/components/CartPopover/CartPopover.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ const styles = (theme) => ({
6464
}
6565
});
6666

67-
@withStyles(styles, { withTheme: true })
67+
@withStyles(styles, { withTheme: true, name: "SkCartPopover" })
6868
@inject("uiStore")
6969
@observer
7070
class CartPopover extends Component {

src/components/CartPopover/__snapshots__/CartPopover.test.js.snap

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,26 @@ exports[`do not show cartpopover 1`] = `
55
className="HiddenCss-mdUp-16"
66
>
77
<div
8-
className="inject-CartPopover-with-uiStore-container-1 inject-CartPopover-with-uiStore-isContainerHidden-3"
8+
className="SkCartPopover-container-1 SkCartPopover-isContainerHidden-3"
99
>
1010
<div
11-
className="MuiGrid-container-24 MuiGrid-spacing-xs-24-48 inject-CartPopover-with-uiStore-gridContainer-2"
11+
className="MuiGrid-container-24 MuiGrid-spacing-xs-24-48 SkCartPopover-gridContainer-2"
1212
>
1313
<div
14-
className="MuiGrid-item-25 MuiGrid-grid-xs-12-64 inject-CartPopover-with-uiStore-containerItem-5"
14+
className="MuiGrid-item-25 MuiGrid-grid-xs-12-64 SkCartPopover-containerItem-5"
1515
>
1616
<img
1717
alt="Item Title"
18-
className="inject-CartPopover-with-uiStore-addedToCartImg-6"
18+
className="SkCartPopover-addedToCartImg-6"
1919
src="//placehold.it/100"
2020
/>
2121
<span
22-
className="MuiTypography-root-121 MuiTypography-body1-130 inject-CartPopover-with-uiStore-addedToCartText-8"
22+
className="MuiTypography-root-121 MuiTypography-body1-130 SkCartPopover-addedToCartText-8"
2323
>
2424
10
2525
"
2626
<span
27-
className="inject-CartPopover-with-uiStore-addedToCartItemName-7"
27+
className="SkCartPopover-addedToCartItemName-7"
2828
>
2929
Item Title
3030
</span>
@@ -67,26 +67,26 @@ exports[`show cartpopover 1`] = `
6767
className="HiddenCss-mdUp-16"
6868
>
6969
<div
70-
className="inject-CartPopover-with-uiStore-container-1 inject-CartPopover-with-uiStore-isContainerVisible-4"
70+
className="SkCartPopover-container-1 SkCartPopover-isContainerVisible-4"
7171
>
7272
<div
73-
className="MuiGrid-container-24 MuiGrid-spacing-xs-24-48 inject-CartPopover-with-uiStore-gridContainer-2"
73+
className="MuiGrid-container-24 MuiGrid-spacing-xs-24-48 SkCartPopover-gridContainer-2"
7474
>
7575
<div
76-
className="MuiGrid-item-25 MuiGrid-grid-xs-12-64 inject-CartPopover-with-uiStore-containerItem-5"
76+
className="MuiGrid-item-25 MuiGrid-grid-xs-12-64 SkCartPopover-containerItem-5"
7777
>
7878
<img
7979
alt="Item Title"
80-
className="inject-CartPopover-with-uiStore-addedToCartImg-6"
80+
className="SkCartPopover-addedToCartImg-6"
8181
src="//placehold.it/100"
8282
/>
8383
<span
84-
className="MuiTypography-root-121 MuiTypography-body1-130 inject-CartPopover-with-uiStore-addedToCartText-8"
84+
className="MuiTypography-root-121 MuiTypography-body1-130 SkCartPopover-addedToCartText-8"
8585
>
8686
10
8787
"
8888
<span
89-
className="inject-CartPopover-with-uiStore-addedToCartItemName-7"
89+
className="SkCartPopover-addedToCartItemName-7"
9090
>
9191
Item Title
9292
</span>

src/components/CheckoutActions/CheckoutActions.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export default class CheckoutActions extends Component {
4141
// Omit firstName, lastName props as they are not in AddressInput type
4242
// The address form and GraphQL endpoint need to be made consistent
4343
const { firstName, lastName, ...rest } = address;
44-
onSetShippingAddress({
44+
return onSetShippingAddress({
4545
fullName: `${address.firstName} ${address.lastName}`,
4646
...rest
4747
});
@@ -55,7 +55,7 @@ export default class CheckoutActions extends Component {
5555
fulfillmentMethodId: shippingMethod.selectedFulfillmentOption.fulfillmentMethod._id
5656
};
5757

58-
onSetFulfillmentOption(fulfillmentOption);
58+
return onSetFulfillmentOption(fulfillmentOption);
5959
}
6060

6161
setPaymentMethod = (stripeToken) => {
@@ -102,6 +102,10 @@ export default class CheckoutActions extends Component {
102102
}
103103

104104
render() {
105+
if (!this.props.cart) {
106+
return null;
107+
}
108+
105109
const { cartStore: { stripeToken } } = this.props;
106110
const { checkout: { fulfillmentGroups, summary }, items } = this.props.cart;
107111
const shippingAddressSet = isShippingAddressSet(fulfillmentGroups);

0 commit comments

Comments
 (0)