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

"Extending" Themes #277

Closed
kitsonk opened this issue Aug 11, 2017 · 2 comments
Closed

"Extending" Themes #277

kitsonk opened this issue Aug 11, 2017 · 2 comments
Assignees
Milestone

Comments

@kitsonk
Copy link
Member

kitsonk commented Aug 11, 2017

User Story

As a developer, I need a clear pattern for extending themes, taking an existing theme and adding additional widget classes, additional styles to widgets, and potentially overriding some of the theme styles.

Specific Use Case

I have a corporate theme which has been provided. Our project requires that we add/adjust some of the styles for our project, therefore I need to extend that base theme. I do not expect to utilise !important to achieve this.

@kitsonk kitsonk added this to the 2017.08 milestone Aug 11, 2017
@kitsonk kitsonk modified the milestones: 2017.08, 2017.09 Sep 4, 2017
@eheasley eheasley added beta4 and removed beta3 labels Oct 3, 2017
@eheasley eheasley modified the milestones: 2017.09, 2017.10 Oct 6, 2017
@tomdye
Copy link
Member

tomdye commented Oct 20, 2017

I believe that in this situation you would take the corporate theme as a base. In your new theme you would re-export the parts of the base theme that you want to use as-is and would utilise compose to customise and change the theme for particular components.

example

/* base/theme.ts */
import * as textInput from './textInput.m.css';
import * as button from './button.m.css';

export default {
   textInput,
   button
};
/* custom/theme.ts */
import * as textInput from '../base/textInput.m.css'; // use base textInput theme
import * as button from './button.m.css'; // use custom button style

export default {
   textInput,
   button
};
/* custom/button.m.css */
.root {
   /* use root class from base theme */
   composes 'root' from '../base/button.m.css'; 
}

.text {
   /* provide new text class */
   color: red;
}

@bitpshr
Copy link
Member

bitpshr commented Oct 20, 2017

Thanks for the explanation @tomdye. I like the idea of exporting a custom theme that either explicitly exports base component styles as-is, or exports custom styles that use @composes to extend the base styles. I like that this can be on a per-component basis, too. I also think that potential tooling developed as part of #276 could ease the pain of knowing what classes must be extended if passing custom styles.

I think this information should be captured in a tutorial.

Action items:

@bitpshr bitpshr closed this as completed Oct 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants