Skip to content
This repository was archived by the owner on Nov 16, 2023. It is now read-only.

Commit 8d28645

Browse files
authored
Remove global CSS resets and base styling (#507)
* Move paragraph styling to a new Paragraph component * Replace all example paragraphs in .md files * Remove heading tag styles * Replace global b and strong styles with Strong component * Replace all example usages of strong tags * Remove unnecessary global base element styles * Create Emphasis component replace em tag * Replace em tags with Emphasis in all examples * Replace Fabric componet with AppContainer component * Use AppContainer to wrap examples * Fix missing font-family styles due to Fabric theme not deeply-merging our theme * Fix theme tests * Remove base/reset CSS, move the few absolutely necessary styles to global mergeStyles selector * Update snapshots and visual diffs * Fix theme, update AppContainer snapshots
1 parent cb961f6 commit 8d28645

File tree

136 files changed

+738
-621
lines changed

Some content is hidden

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

136 files changed

+738
-621
lines changed

package-lock.json

Lines changed: 0 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
"url": "https://github.com/Microsoft/YamUI.git"
1111
},
1212
"dependencies": {
13-
"normalize.css": "6.0.0",
1413
"office-ui-fabric-react": "6.25.0",
1514
"@researchgate/react-intersection-observer": "0.7.3"
1615
},
Lines changed: 12 additions & 0 deletions
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*! Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. */
2+
import { mergeStyleSets, ITheme } from 'office-ui-fabric-react/lib/Styling';
3+
import { memoizeFunction } from 'office-ui-fabric-react/lib/Utilities';
4+
import { textColors, fontWeights } from '../../util/styles/fonts';
5+
6+
export interface AppContainerClassNameProps {
7+
theme: ITheme;
8+
}
9+
10+
export const getClassNames = memoizeFunction((props: AppContainerClassNameProps) => {
11+
const { theme } = props;
12+
const font = theme.fonts.medium;
13+
14+
return mergeStyleSets({
15+
root: {
16+
color: textColors(theme).primary,
17+
fontSize: font.fontSize,
18+
lineHeight: font.lineHeight,
19+
fontWeight: fontWeights.normal,
20+
21+
selectors: {
22+
':global(html)': {
23+
/* Sets 1.0rem to 10px */
24+
fontSize: '62.5%',
25+
boxSizing: 'border-box',
26+
},
27+
':global(*, *::before, *::after)': {
28+
boxSizing: 'inherit',
29+
},
30+
},
31+
},
32+
});
33+
});
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*! Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. */
2+
import * as React from 'react';
3+
import { shallow, ShallowWrapper } from 'enzyme';
4+
import { NestableBaseComponentProps } from '../../util/BaseComponent/props';
5+
import AppContainer from '.';
6+
7+
describe('<AppContainer />', () => {
8+
let component: ShallowWrapper<NestableBaseComponentProps>;
9+
10+
describe('with default options', () => {
11+
beforeEach(() => {
12+
component = shallow(<AppContainer>paragraph text</AppContainer>);
13+
});
14+
15+
it('matches its snapshot', () => {
16+
expect(component).toMatchSnapshot();
17+
});
18+
});
19+
20+
describe('with className', () => {
21+
beforeEach(() => {
22+
component = shallow(<AppContainer className="TEST_CLASSNAME">paragraph text</AppContainer>);
23+
});
24+
25+
it('matches its snapshot', () => {
26+
expect(component).toMatchSnapshot();
27+
});
28+
});
29+
});
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*! Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. */
2+
import '../../yamui';
3+
import * as React from 'react';
4+
import { join } from '../../util/classNames';
5+
import { Fabric } from 'office-ui-fabric-react/lib/Fabric';
6+
import { CustomizableComponentProps, defaultTheme } from '../Customizer';
7+
import { NestableBaseComponentProps } from '../../util/BaseComponent/props';
8+
import { getClassNames } from './AppContainer.styles';
9+
10+
/**
11+
* AppContainer sets some baseline visual and accessibility styling.
12+
*/
13+
export default class AppContainer extends React.Component<NestableBaseComponentProps & CustomizableComponentProps> {
14+
public render() {
15+
const { children, className, theme = defaultTheme } = this.props;
16+
const classNames = getClassNames({ theme });
17+
return (
18+
<Fabric>
19+
<div className={join(['y-appContainer', classNames.root, className])}>{children}</div>
20+
</Fabric>
21+
);
22+
}
23+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`<AppContainer /> with className matches its snapshot 1`] = `
4+
<CustomizedFabric>
5+
<div
6+
className=
7+
y-appContainer
8+
TEST_CLASSNAME
9+
{
10+
color: #343a41;
11+
font-size: 1.5rem;
12+
font-weight: 400;
13+
line-height: 2.0rem;
14+
}
15+
html {
16+
box-sizing: border-box;
17+
font-size: 62.5%;
18+
}
19+
*, *::before, *::after {
20+
box-sizing: inherit;
21+
}
22+
>
23+
paragraph text
24+
</div>
25+
</CustomizedFabric>
26+
`;
27+
28+
exports[`<AppContainer /> with default options matches its snapshot 1`] = `
29+
<CustomizedFabric>
30+
<div
31+
className=
32+
y-appContainer
33+
{
34+
color: #343a41;
35+
font-size: 1.5rem;
36+
font-weight: 400;
37+
line-height: 2.0rem;
38+
}
39+
html {
40+
box-sizing: border-box;
41+
font-size: 62.5%;
42+
}
43+
*, *::before, *::after {
44+
box-sizing: inherit;
45+
}
46+
>
47+
paragraph text
48+
</div>
49+
</CustomizedFabric>
50+
`;

src/components/AppContainer/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/*! Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. */
2+
export { default } from './AppContainer';
3+
export * from './AppContainer';

src/components/Avatar/Avatar.md

Lines changed: 1 addition & 1 deletion

0 commit comments

Comments
 (0)