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

Load page-specific styles separate from global styles #253

Open
anselmbradford opened this issue Feb 17, 2015 · 4 comments
Open

Load page-specific styles separate from global styles #253

anselmbradford opened this issue Feb 17, 2015 · 4 comments
Labels
build process code.gov See https://github.com/GSA/code-gov/blob/master/HelpWanted.md [effort] large [featured] See https://github.com/GSA/code-gov/blob/master/HelpWanted.md#featured Front-end help wanted [skill-level] advanced

Comments

@anselmbradford
Copy link
Member

The CSS contains what appears to be component-specific styles (e.g. https://github.com/cfpb/cfgov-refresh/blob/gh-pages/static/css/activity.less) and page-specific styles (e.g. https://github.com/cfpb/cfgov-refresh/blob/gh-pages/static/css/budget.less).

Could page-specific and/or components go in their own sub-directory with static/css and appropriate documentation be provided where topdoc comments are not provided?

cc @Scotchester @virginiacc

@Scotchester
Copy link
Contributor

Yes, putting page-specific CSS in a subdirectory is a good idea. Moreover, at some point, we want a solution for loading page-specific CSS ONLY on the pages that require it. Otherwise, we'll have one gigangtic singular CSS file.

@anselmbradford
Copy link
Member Author

anselmbradford commented Feb 17, 2015

@anselmbradford anselmbradford changed the title Disambiguate page-specific and component styles Load page-specific styles separate from global styles Jul 6, 2015
@anselmbradford anselmbradford added help wanted Front-end code.gov See https://github.com/GSA/code-gov/blob/master/HelpWanted.md [featured] See https://github.com/GSA/code-gov/blob/master/HelpWanted.md#featured [effort] large [skill-level] advanced labels Apr 18, 2018
@GrooveCS
Copy link

GrooveCS commented Sep 1, 2020

Is this still an Open Issue?

@anselmbradford
Copy link
Member Author

Hi @GrooveCS, to an extent. We have the majority of our CSS in https://github.com/cfpb/consumerfinance.gov/blob/master/cfgov/unprocessed/css/main.less, but we do have "apps" that have their CSS and other assets isolated from the rest of the code, e.g. https://github.com/cfpb/consumerfinance.gov/tree/master/cfgov/unprocessed/apps/owning-a-home/css has its own main.less, which is only delivered to that app (live site) via the reference in its template https://github.com/cfpb/consumerfinance.gov/blob/master/cfgov/jinja2/v1/owning-a-home/explore-rates/index.html#L19

However, when a component is included in a page via the Wagtail CMS, that component's JavaScript gets added to the page, but its CSS is delivered everywhere. We should probably have something analogous for the CSS to how the JS works, so that the component's CSS is added into the page's CSS bundle somehow when it's included in a page via Wagtail, and exclude it otherwise. For example, the video player JS is added here, but the CSS for the video player is together with everything else in main.less https://github.com/cfpb/consumerfinance.gov/blob/master/cfgov/unprocessed/css/main.less#L129

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build process code.gov See https://github.com/GSA/code-gov/blob/master/HelpWanted.md [effort] large [featured] See https://github.com/GSA/code-gov/blob/master/HelpWanted.md#featured Front-end help wanted [skill-level] advanced
Projects
None yet
Development

No branches or pull requests

4 participants