-
Notifications
You must be signed in to change notification settings - Fork 49
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
background-*
passthrough or singular pseudo-Element styling?
#20
Comments
Well, the question is whether to follow I personally prefer not styling through props, it's as if mixing two things... How about supporting both ways? |
Oh, I misspelled myself, will edit it in the original question - no further props were added. Wanted to stay in sync with |
Current version now is |
Hi, @timhagn I think it's not a big problem since it's possible to attach some class name to By the way I don't really like the idea of passing css through the props since we already have css :) |
Hi @apaulau! Thanks for your input, greatly appreciated! Point 1 only concerns specific Right now (at least when I try it in
But maybe I'm just overthinking it oO? EDIT: Clarification of style-concerns and addition of |
Hi @timhagn, I think all background-related properties should be parsed with getBackgroundStyles() anyways. However, leave the opportunity to override style using props. Let's say move all
etc. Into one single <Background
fluid={image}
style={{
backgroundPosition: 'center center',
backgroundSize: '100% 50%',
backgroundAttachment: 'scroll',
backgroundOrigin: 'border-box'
}}
>
Text
</Background> Instead of specifying every single property (which is kind of annoying): <Background
fluid={image}
backgroundPosition: 'center center'
backgroundSize: '100% 50%'
backgroundAttachment: 'scroll'
backgroundOrigin: 'border-box'
>
Text
</Background> Hope this makes sense. |
Hi @r007, thanks for the input, though to clear up the misconception again (EDIT3 in the Original post), From the rest you were writing, might I guess you'd prefer option 2 (Just pass every Or would you want to include option 3 from above, too? Thanks again and in advance, Tim. |
@timhagn, yes option 2. Outer class <BackgroundImage id="Hero" className="Hero">
Some content
</BackgroundImage> .Hero:before,
.Hero:after {
background-position: center;
} It's basically the same. But like I said, would be nice to have ability to override styles through inline <Background
fluid={image}
style={{
backgroundPosition: 'center center',
backgroundSize: '100% 50%',
backgroundAttachment: 'scroll',
backgroundOrigin: 'border-box'
}}
>
Text
</Background> Option 3 is not really needed I think. It would be too computationally intensive to parse every :before & :after selector. So options 1 & 2 I think... |
Aaah, I see, thanks! Actually I was pretty sure that I'm rewriting So I'm okay with either of option 1 or option 2 and agree with @r007 regarding option 3. Actually his inline style proposal also looks nice. |
Enjoy! 🎉
…On 1 Apr 2019, 18:19 +0200, Tim Hagn ***@***.***>, wrote:
Hi @r007, @apaulau and all others : )!
Thanks for your thoughts and input, gonna revisit it tomorrow,
cause today my wife and I are celebrating our 12th relationship anniversary,
so no coding for me today ; )!
Have a nice day and read you tomorrow,
Tim.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
@petrpacas Thanks, was a more than nice evening night - am still recuperating % ). EDIT: And to everyone: no, it wasn't a joke - though we might just be the ultimate April Fool's One ^^. |
Hi all! Recuperation took a little longer, so yesterday no more than merging in @davebra's PR #23, a few adaptions and publishing So on to what has changed and some more clarifying answers (& questions):
To answer your above comment, @r007 (and add a question ; ):
Thanks again and in advance, Tim. P.S.: @apaulau, could you please clarify your above comment and which specific hack you used (perhaps with some example code)?
EDIT: You can now see the above mentioned and slowly integrated changes in the branch: |
Latest version now is |
There's just too much stuff to read/answer, man :-) From my point of view:
|
@petrpacas Thanks, these were nice and concise answers (yip, I tend to over-elaborate and do like chain-sentences, indeed ^^)! With 2. and 4. you charge an open door with me, as those were my lines of thoughts as well. Thanks again for your opinions! Hope the others chime in soon ; ). |
Sure, here it is: <BackgroundImage classNames="class1 class2" /> .class1::before,
.class1::after {...}
.class1.class2::before,
.class1.class2::after {
background-size: 42% 42%;
} Obviously |
Thanks, @apaulau! |
Oh, and we are now at |
@timhagn |
Thnx for your inputs! The current state now is in the branch I'm trying to deprecate the special How long do you think we should drag the old behavior with us (really until |
Till 1.0.0 is probably a good idea. Although I really wonder how many people took advantage of that. I found it easy enough to style with css modules so never felt I needed to target the id. |
@itwasmattgregg Thought about only taking them with us (pre-announced, of course) until 0.5.0 (yeah, I should have stuck to SemVer since the beginning ; ), or at least adding deprecation warnings right from the next version... Don't really know if anyone used it (except me in one small project, that is % ), but perhaps we'd get to know them in some issues after adding the warnings ^^. |
Now we are at |
Hi to all of you! A little more has happened:
In Please test extensively : )! Should any of your tests reveal problems, just open an issue (or a PR, always welcome % )! Should there be no hiccups on your sides, I'm gonna close this issue on Wednesday. Fingers crossed, |
The cached image not fading in is a funny thing - I noticed it w/ I'd say that it's best to keep the behaviour in sync w/ |
@petrpacas Yup, seems a little strange - but I prefer synchronicity with |
|
I wanted to suggest to add a prop for that, but you beat me to it - and I see (https://www.gatsbyjs.org/packages/gatsby-image/#gatsby-image-props) |
@petrpacas The As I thought it might be useful sometimes (have a case right now on image data change) to "force" a softer fade in, I just overloaded it with |
As no one else raised any flags and we're now at |
Hi there,
wanted to ask all who invested some of their time into this project a question, which came up through @r007's PR #17 (now integrated in the just published
0.2.8-alpha3
):How should
gatsby-background-image
handle background styling?There are three ways coming to my mind:
backgroundSize
,backgroundRepeat
and (with Add background-position property to background image #17)backgroundPosition
parsed withgetBackgroundStyles()
through to the the pseudo-Elements.background-*
CSS Property parsed withgetBackgroundStyles()
through to the pseudo-Elements.document.styleSheets
contains every::before & ::after
Element written as they are in CSS / constructed bystyled-components
and suchlike CSS-in-JS solutions written like.frjXhE::after, .frjXhE::before
in aCSSStyleRule
'sselectorText
when created bystyled-components
thus way:(It works nearly the same for media-queries, by the way : )!
What do you think? Which should be the way to go in your opinion?
Thanks in advance,
Tim.
@r007 @ambethia @einarbirgir @milanito @nshoes @petrpacas @EricSSartorius @apaulau @drobinhood @adam-wheatley @itwasmattgregg @AlmeroSteyn - and everyone wanting to speak up on this question : )
EDIT: Fixed the structure of my first sentence and added the new published
0.2.8-alpha2
version.EDIT2: Changed
0.2.8-alpha2
to current version0.2.8-alpha3
.EDIT3: Changed wrong usage of "props" in 1. to a better explanation, also see my comment below.
The text was updated successfully, but these errors were encountered: