Skip to content

Conversation

@jschuler
Copy link
Collaborator

Closes: #1189

Is there a better way? Guess this css is globally added for consumers

@patternfly-build
Copy link
Collaborator

PatternFly-React preview: https://1244-pr-patternfly-react-patternfly.surge.sh

import PopoverHeader from './PopoverHeader';
import PopoverCloseButton from './PopoverCloseButton';
import GenerateId from '../../internal/GenerateId/GenerateId';
import 'tippy.js/dist/tippy.css';
Copy link
Contributor

Choose a reason for hiding this comment

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

This comes back to requiring users to load CSS and forces them to set up min-css-loader, styled-loader, mini-css-plugin. As for a way around it could do

  1. Use something other than Tippy. Maybe check to see what Material-UI does. They may have written their own though.
  2. Modify the babel plugin to support loading external CSS and inject it.
  3. Write a script to generate a file that loads the CSS and then uses injectGlobal to inject it.
  4. Leave it and require consumers to use webpack, css loaders, etc.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I could go with 3, use raw-loader to get the string and then use emotion injectGlobal to inject it

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Just thought of this, we already recommend they import this to get the base css, wouldn't this fall under the same issues you listed?
import '@patternfly/react-core/dist/styles/base.css';

Copy link
Contributor

Choose a reason for hiding this comment

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

For the base css that is not the only way to load it. It is also possible to copy it to a public direct, etc. Either way the user has to explicitly import it so it is assumed they know how to set that up. Instead of us assuming they have a good build in place. As for raw loader. It is the same deal. We would assume they have raw loader setup.

I had in the future planned to make a provider that added the base css for the user, but I admittly have decided to not contribute anymore code. Unless something I wrote needs fixed.

I am ok with any option you go with I just wanted you to be aware that this could potentially be a breaking change and will need documentated well

Copy link
Member

@priley86 priley86 Jan 25, 2019

Choose a reason for hiding this comment

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

I believe I was hitting the same problem in #1250 while trying to include an example CSS file...

I ended up just using gatsby-plugin-sass with iso-morphic-style-loader for the time being:
priley86@219c3ac

I plan to drop this commit unless we determine it useful for others. FWIW, there is a really good list of supported CSS options in Gatsby here:
https://www.gatsbyjs.org/tutorial/part-two/#component-css

Would be really nice to see gatsby-plugin-sass and gatsby-plugin-emotion support in PF-React. To @dmiller9911's point, this may put some impetus on the consumer to use a webpack loader, so it might be worth asking around first...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've just copied the source for now and am injecting it along with my overrides using emotion

Copy link
Member

Choose a reason for hiding this comment

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

yea i was having trouble w/ the plugins mentioned above. This may be the easiest route for now...

@coveralls
Copy link

coveralls commented Jan 24, 2019

Pull Request Test Coverage Report for Build 4280

  • 5 of 5 (100.0%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 80.225%

Totals Coverage Status
Change from base Build 4260: 0.0%
Covered Lines: 4632
Relevant Lines: 5424

💛 - Coveralls

Copy link
Contributor

@tlabaj tlabaj left a comment

Choose a reason for hiding this comment

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

LGTM. Just needs conflicts resolved.

import { StyleSheet } from '@patternfly/react-styles';

// inject the base tippy styles ('tippy.js/dist/tippy.css')
export const tippyStyles = StyleSheet.parse(
Copy link
Contributor

Choose a reason for hiding this comment

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

This can just use injectGlobal it will be faster since parse runs some regexs on the string.


// Need to unset tippy default styles
// Also for enableFlip, need to make arrow aware of parent x-placement attribute in order to work
export const overrides = StyleSheet.parse(`
Copy link
Contributor

Choose a reason for hiding this comment

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

injectGlobal can be used here too.

tlabaj
tlabaj previously approved these changes Jan 31, 2019
Copy link
Contributor

@tlabaj tlabaj left a comment

Choose a reason for hiding this comment

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

LGTM

kmcfaul
kmcfaul previously approved these changes Jan 31, 2019
@jschuler jschuler dismissed stale reviews from kmcfaul and tlabaj via 745a6f2 February 4, 2019 01:57
tlabaj
tlabaj previously approved these changes Feb 4, 2019
Copy link
Contributor

@tlabaj tlabaj left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@tlabaj tlabaj left a comment

Choose a reason for hiding this comment

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

LGTM

@dlabaj dlabaj merged commit 469477a into patternfly:master Feb 4, 2019
dgutride pushed a commit to dgutride/patternfly-react that referenced this pull request Feb 6, 2019
* fix(PF4): tooltip/popover - include tippy css

* add a jest transform ignore pattern for tippy

* emotion for styling

* rebase

* ts

* ts definitions

* snapshot

* prod build
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

Successfully merging this pull request may close these issues.

8 participants