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

Styling: integrating glamor based styling, removing fabric-core dependency #1837

Merged
merged 86 commits into from
May 29, 2017

Conversation

dzearing
Copy link
Member

@dzearing dzearing commented May 23, 2017

Addresses #983

Description of changes

Problems we're aiming to solve:

  1. Ensure all components work out of the box. No dependency on global css.
  2. All css rules are versioned.
  3. Open up a path for richer styling which has better control over rule specificity and RTL sensitivity.
  4. Support a more robust theming approach.

This change does a couple of things:

  1. It creates a dependency on the @uifabric/styling package. This package is still shuffling, but we want to take an early dependency on it and gradually migrate our CSS story.

  2. It completely removes all global css references. There are zero references to ms-font-, ms-u-animation-, ms-icon-*. That means out of the box things will work correctly without needed stylesheets.

  3. Redoes the button styles using glamor. The existing rules have remained intact; we just use glamor to register them. And, if you provide custom rules, we have an opportunity to mix those in, and ensure that we control specificity; the overrides always win.

dzearing added 30 commits April 27, 2017 13:40
… This will help identify how we're impacting the bundle size of the button, and will help validate that we're actually able to render a button without fabric-core.
… replacement css utility that works better mixing glamor styling and class name strings together.
…erstandable rules that don't rely on non-contractual css child selectors to do anything. Updated Primary button to not use sass.
…c-react into styling-updates

# Conflicts:
#	apps/fabric-website/package.json
#	common/npm-shrinkwrap.json
#	common/temp_modules/rush-example-app-base/package.json
#	common/temp_modules/rush-example-component/package.json
#	common/temp_modules/rush-fabric-website/package.json
#	common/temp_modules/rush-office-ui-fabric-react/package.json
#	common/temp_modules/rush-styling/package.json
#	common/temp_modules/rush-todo-app/package.json
#	packages/example-app-base/package.json
#	packages/office-ui-fabric-react/package.json
#	packages/office-ui-fabric-react/src/components/pickers/BasePicker.tsx
#	packages/office-ui-fabric-react/src/utilities/decorators/withContainsFocus.tsx
#	packages/styling/package.json
#	tslint.json
…c-react into styling-updates

# Conflicts:
#	apps/fabric-website/package.json
#	common/npm-shrinkwrap.json
#	common/temp_modules/rush-example-app-base/package.json
#	common/temp_modules/rush-fabric-website/package.json
#	common/temp_modules/rush-office-ui-fabric-react/package.json
#	common/temp_modules/rush-styling/package.json
#	packages/example-app-base/package.json
…c-react into styling-updates

# Conflicts:
#	common/npm-shrinkwrap.json
#	packages/example-app-base/package.json
#	packages/office-ui-fabric-react/package.json
…c-react into styling-updates

# Conflicts:
#	packages/office-ui-fabric-react/src/components/Persona/examples/Persona.Basic.Example.tsx
Copy link
Member

@christiango christiango left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm always a fan of a change that removes more code than it adds

@@ -148,7 +157,7 @@ export class Breadcrumb extends BaseComponent<IBreadcrumbProps, IBreadcrumbState
}

@autobind
private _onOverflowClicked(ev: React.MouseEvent<HTMLElement>) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reason for dropping the type here?

@@ -12,6 +13,32 @@ export interface IButton {
focus: () => void;
}

export interface IButtonStyles {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments to help people realize which is the appropriate style to override for customization?

const DEFAULT_BUTTON_HEIGHT = '32px';
const DEFAULT_PADDING = '0 4px';

export function getStyles(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No memoize?

@@ -40,15 +40,15 @@ export function getRTL(): boolean {
/**
* Sets the rtl state of the page (by adjusting the dir attribute of the html element.)
*/
export function setRTL(isRTL: boolean) {
export function setRTL(isRTL: boolean, avoidPersisting = false) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:)

@micahgodbolt
Copy link
Member

pulling this down for a look as well

getStyles as getDefaultButtonStyles
} from '../DefaultButton/DefaultButton.styles';

export function getStyles(
Copy link
Member

@micahgodbolt micahgodbolt May 23, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels like a bunch of boilerplate. theme, custom styles, palette...can we/should we abstract some of that away?

export function getStyles(
  theme: ITheme = getTheme(),
  customStyles?: IButtonStyles,
): IButtonStyles {
  let { palette } = theme;

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not really sure. Styles are a function of the theme and of customStyles.

It is possible that we can pull the "global" theme, but it removes the ability to override the theme in a context.

It is possible to not take in customStyles, and to instead mix them in from within the component itself.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not saying to change any of the functionality. custom themes are obviously important. Just curious if we can wrap it up and abstract what I'm sure will end up in just about every styles file.

If you think this is about as abstract as you want to get right now, no worries. We can always tweak it later.

Copy link
Member

@micahgodbolt micahgodbolt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than a small question about function abstraction, i love this. It could also use an example where we override some styles.

dzearing and others added 20 commits May 23, 2017 16:24
…c-react into styling-updates

# Conflicts:
#	common/temp_modules/rush-example-app-base/package.json
#	common/temp_modules/rush-office-ui-fabric-react/package.json
#	common/temp_modules/rush-utilities/package.json
#	packages/example-app-base/package.json
#	packages/office-ui-fabric-react/package.json
#	packages/utilities/package.json
…xed mergeStyleSets so that you don’t have to specify “undefined” for non styled things in the base class.
* add semantic colors and convert nonhover toggle colors to use them

* fix lint error

* address code review feedback and better comment

* wip: finishing up toggle, still have disabled thumb color bug to address

* update toggle to new way of doing things

* code review feedback

* cleanup

* umm, updates and stuff

* cleanup for merge

* fix lint errors
…c-react into styling-updates

# Conflicts:
#	packages/example-app-base/package.json
#	packages/office-ui-fabric-react/package.json
…c-react into styling-updates

# Conflicts:
#	common/temp_modules/rush-example-app-base/package.json
#	common/temp_modules/rush-office-ui-fabric-react/package.json
#	common/temp_modules/rush-styling/package.json
#	common/temp_modules/rush-utilities/package.json
#	packages/example-app-base/package.json
#	packages/office-ui-fabric-react/package.json
#	packages/office-ui-fabric-react/src/components/Button/BaseButton.scss
#	packages/office-ui-fabric-react/src/components/Callout/CalloutContent.tsx
#	packages/office-ui-fabric-react/src/components/Check/Check.scss
#	packages/office-ui-fabric-react/src/components/DetailsList/DetailsRow.tsx
#	packages/office-ui-fabric-react/src/components/Fabric/Fabric.tsx
#	packages/office-ui-fabric-react/src/components/Image/Image.tsx
#	packages/office-ui-fabric-react/src/components/Layer/examples/Layer.Basic.Example.tsx
#	packages/office-ui-fabric-react/src/components/Layer/examples/Layer.Hosted.Example.tsx
#	packages/office-ui-fabric-react/src/components/List/examples/List.Mail.Example.scss
#	packages/office-ui-fabric-react/src/components/Nav/Nav.tsx
#	packages/office-ui-fabric-react/src/components/Panel/Panel.tsx
#	packages/office-ui-fabric-react/src/components/TextField/TextField.tsx
#	packages/office-ui-fabric-react/src/components/Tooltip/Tooltip.tsx
#	packages/styling/package.json
…-ui-fabric-react into styling-updates

# Conflicts:
#	packages/example-app-base/package.json
#	packages/office-ui-fabric-react/package.json
#	packages/office-ui-fabric-react/src/components/Toggle/Toggle.scss
@dzearing dzearing merged commit 3a198d4 into master May 29, 2017
@dzearing dzearing deleted the styling-updates branch May 29, 2017 19:29
@microsoft microsoft locked as resolved and limited conversation to collaborators Aug 31, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants