Skip to content
This repository has been archived by the owner on Mar 27, 2021. It is now read-only.

Issues with styling CardElement with styletron and Baseweb #436

Closed
matchatype opened this issue Sep 25, 2019 · 3 comments
Closed

Issues with styling CardElement with styletron and Baseweb #436

matchatype opened this issue Sep 25, 2019 · 3 comments

Comments

@matchatype
Copy link

I've been quite successful at styling the component to integrate it with styletron and Baseweb, but I'm not able to replicate styles for pseudo-classes so, with my current implementation I am not able to pass the correct styling to the parent... because of how styletron works. Here is how I implemented CardElement:

<FormControl label="Credit card details">
  <Block
    $as={CardElement}
    className={useCss({
      backgroundColor: theme.colors.mono300,
      borderRadius: theme.borders.radius200,
      borderWidth: theme.sizing.scale0,
      borderStyle: theme.borders.border100.borderStyle,
      borderColor: theme.colors.mono300,
      paddingBottom: theme.sizing.scale400,
      paddingLeft: theme.sizing.scale550,
      paddingRight: theme.sizing.scale550,
      paddingTop: theme.sizing.scale400,
    })}
    style={{base: {...theme.typography.font300}}}
  />
</FormControl>

and here is how it looks next to a regular Baseweb component.

CleanShot 2019-09-25 at 14 28 44@2x

Probably my implementation is not correct, and I can achieve the desired result by simply hooking in the style prop of the CardElement itself, but I've not been successful that way. Any idea on how could I set styles for the container, so I can change settings for border, backgroundColor and transition on focus? Here is an example:

Screen Capture on 2019-09-25 at 14-51-41

@oliver-stripe
Copy link
Contributor

I'm not familiar with styletron, but we have examples of styling the input on focus at https://stripe.dev/elements-examples/ that you can use as a guide.

Outside of that, if programmatically determining focus/blur can be useful (such that you can track the state yourself and adjust variables/classes/etc/ accordingly), there are events you can subscribe to: https://stripe.com/docs/stripe-js/reference#element-on

@matchatype
Copy link
Author

matchatype commented Sep 28, 2019

[edited reference to wrong user]
@oliver-stripe That did the job, thank you for the tip! However, it would be great if you could expose some sort of api for the parent too, so these kind of things can be set easily without much overhead.

@oleolek-stripe
Copy link

I think it should be @oliver-stripe

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants