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

[POC] Styled render callback component and refactored withStyles #9503

Closed
wants to merge 21 commits into from
Closed
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
1362466
switch prettier config to yaml
rosskevin Dec 15, 2017
a36895b
prototype - Styled render callback and withStyles refactoring
rosskevin Dec 15, 2017
f045ce6
fix getClasses helper to mount and obtain the styleSheet via sheetsRe…
rosskevin Dec 15, 2017
73fbad0
bad prop
rosskevin Dec 15, 2017
bf74fdd
rename dummy field class name to prevent confusion
rosskevin Dec 15, 2017
a56befa
I’m wrong about the props being modified - this proves it.
rosskevin Dec 15, 2017
0fe9008
hack showing difference causing sheet growth
rosskevin Dec 15, 2017
8be0604
proof that getStylesCreator creates a different result with same styl…
rosskevin Dec 15, 2017
52e2603
oops, NOW this proves it. sneaky.
rosskevin Dec 15, 2017
bb911be
add broken styles function equality test
rosskevin Dec 15, 2017
f42d156
fixed creator as key problem
rosskevin Dec 15, 2017
c042d5c
move the indexCounter into getStylesCreator - more relevant there.
rosskevin Dec 15, 2017
caece9a
fix passing of classes prop
rosskevin Dec 15, 2017
926db46
reestablish innerRef on withStyles
rosskevin Dec 15, 2017
8ff4562
ensure different creators for different style objects - just being pa…
rosskevin Dec 15, 2017
e4934e5
tests checkpoint
rosskevin Dec 15, 2017
7abdf6d
fix resolution of listenToTheme
rosskevin Dec 15, 2017
7717eba
Add tests for withStyles (withTheme) and fix Styled
rosskevin Dec 16, 2017
7060920
more fixes - first other spec green Paper.spec - should be reviewed b…
rosskevin Dec 16, 2017
ff5a53d
name should not be propagated
rosskevin Dec 16, 2017
a41f9e8
decouple props and establish render callback signature
rosskevin Dec 16, 2017
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: 7 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
printWidth: 100
singleQuote: true
trailingComma: all
bracketSpacing: true
jsxBracketSameLine: false
parser: babylon
semi: true
2 changes: 1 addition & 1 deletion docs/src/modules/styles/getContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { create, SheetsRegistry } from 'jss';
import rtl from 'jss-rtl';
import { preset } from 'material-ui/styles/withStyles';
import { preset } from 'material-ui/styles/Styled';
import { createMuiTheme } from 'material-ui/styles';
import blue from 'material-ui/colors/blue';
import pink from 'material-ui/colors/pink';
Expand Down
11 changes: 0 additions & 11 deletions prettier.config.js

This file was deleted.

28 changes: 20 additions & 8 deletions src/Paper/Paper.spec.js
Original file line number Diff line number Diff line change
@@ -1,45 +1,57 @@
import React from 'react';
import { assert } from 'chai';
import { createShallow, getClasses } from '../test-utils';
import { createMount, createShallow, getClasses } from '../test-utils';
import Paper from './Paper';

describe('<Paper />', () => {
let mount;
let shallow;
let classes;

before(() => {
shallow = createShallow({ dive: true });
mount = createMount();
classes = getClasses(<Paper />);
});

it('should render a div', () => {
const wrapper = shallow(<Paper>Hello World</Paper>);
assert.strictEqual(wrapper.name(), 'div');
assert.strictEqual(wrapper.name(), 'Paper');
assert.strictEqual(wrapper.dive().name(), 'div');
});

it('should render with the root class, default depth class, and rounded', () => {
const wrapper = shallow(<Paper>Hello World</Paper>);
const wrapper = mount(<Paper>Hello World</Paper>)
.find('Paper')
.childAt(0);
assert.strictEqual(wrapper.hasClass(classes.root), true);
assert.strictEqual(wrapper.hasClass(classes.rounded), true, 'should be rounded by default');
});

it('should disable the rounded class', () => {
const wrapper = shallow(<Paper square>Hello World</Paper>);
const wrapper = mount(<Paper square>Hello World</Paper>)
.find('Paper')
.childAt(0);
assert.strictEqual(wrapper.hasClass(classes.rounded), false, 'should not be rounded');
});

it('should set the elevation shadow class', () => {
const wrapper = shallow(<Paper elevation={16}>Hello World</Paper>);
const root = mount(<Paper elevation={16}>Hello World</Paper>);
let wrapper = root.find('Paper').childAt(0);
assert.strictEqual(wrapper.hasClass(classes.shadow16), true, 'should have the 16 shadow class');
wrapper.setProps({ elevation: 24 });
root.setProps({ elevation: 24 });
wrapper = root.find('Paper').childAt(0);
assert.strictEqual(wrapper.hasClass(classes.shadow24), true, 'should have the 24 shadow class');
wrapper.setProps({ elevation: 2 });
root.setProps({ elevation: 2 });
wrapper = root.find('Paper').childAt(0);
assert.strictEqual(wrapper.hasClass(classes.shadow2), true, 'should have the 2 shadow class');
});

describe('prop: component', () => {
it('should render a header', () => {
const wrapper = shallow(<Paper component="header">Hello World</Paper>);
const wrapper = mount(<Paper component="header">Hello World</Paper>)
.find('Paper')
.childAt(0);
assert.strictEqual(wrapper.name(), 'header');
});
});
Expand Down
4 changes: 1 addition & 3 deletions src/styles/MuiThemeProvider.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// @flow

import { spy } from 'sinon';
import { assert } from 'chai';
import React from 'react';
Expand All @@ -9,7 +7,7 @@ import JssProvider from 'react-jss/lib/JssProvider';
import { renderToString } from 'react-dom/server';
import { createMount } from '../test-utils';
import createMuiTheme from './createMuiTheme';
import { preset } from './withStyles';
import { preset } from './Styled';
import Button from '../Button';
import createGenerateClassName from './createGenerateClassName';
import withTheme from './withTheme';
Expand Down
Loading