#priya_elements-appearance

1 messages ¡ Page 1 of 1 (latest)

shy turtleBOT
#

👋 Welcome to your new thread!

⏲️ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

🔗 This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1217981103995093043

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

covert oasis
#

Hey @hot barn can you share a screenshot of what you see exactly and what is not working?

#

priya_elements-appearance

hot barn
#

I am trying to send the color for the error messages

#

const options: StripeElementsOptions = {
mode: 'payment',
amount: 20000,
currency: 'eur',
appearance: {
theme: 'stripe',
variables: {
colorPrimary: 'var(--color-blue-dark)',
},
rules: {
'.Error': {
color: 'var(--color-coral-darker)',
fontSize: '0.75rem',
},
'.Input--invalid': {
borderColor: 'var(--color-coral-darker)',
},
},
},
payment_method_types: [
'card',
'bancontact',
'eps',
'giropay',
'ideal',
'sepa_debit',
'sofort',
'demo_pay',
],
};

#

I have it defined :root
--color-coral-darker: #b2443e;

covert oasis
#

ack let me try for a bit

#

Okay so here's some basic code:

const options = {
  appearance: {
    theme: 'stripe',

    variables: {
      colorPrimary: '#0570de',
      colorBackground: '#aaaaaa',
    },
    rules: {
      '.Error': {
        color: '#dddddd',
      },
    }
  }
};```
That immediately changes the color of the error message for me
#

Can you confirm this works for you?

hot barn
#

yes it does work

#

I want to use var to match the common practice

covert oasis
#

okay I don't really get what that means

hot barn
#

okay so instead of using #aaaaaa I want to send the var() defined in :root file

covert oasis
#

what is "the root file"?

hot barn
#

:root {
--color-blue-lighter: #a2cbff;
--color-blue-light: #7091f2;
}

it's global css

#

similar to how we use in normal css file is wht I am trying here.

#

.payNowButton {
width: 100%;
background: var(--color-blue-dark);
}

covert oasis
#

hum sorry CSS is not my forte. Where did you see :root defined? it's not in the code your shared with me

hot barn
#

:root {
--color-blue-lighter: #a2cbff;
--color-blue-light: #7091f2;
}

covert oasis
#

Really sorry can I ask you to share exact end to end code? This wasn't in your previous message for the initialization

hot barn
#

const options: StripeElementsOptions = {
mode: 'payment',
amount: 20000,
currency: 'eur',
appearance: {
theme: 'stripe',
variables: {
colorPrimary: var(--color-blue-dark),
},
rules: {
'.Error': {
color: var(--color-coral-darker),
fontSize: '0.75rem',
},
'.Input--invalid': {
borderColor: '$(var(--color-coral-darker))',
},
},
},
payment_method_types: [
'card',
'bancontact',
'eps',
'giropay',
'ideal',
'sepa_debit',
'sofort',
'demo_pay',
],
};

return (
<Elements stripe={stripePromise} options={options}>
<CheckoutForm />
</Elements>
);

#

I tried multiple solutions

#

using $ etc but non worked

covert oasis
#

yeah I'm just really struggling to even understand the question in the first place. Is your ask "Can I use a global CSS fancy variable with $ in the appearance? Or is your ask "I can't style the color of the error message"?

hot barn
#

okay so I am able to style the error message using #fffff i.e directly giving color code

#

I want to fetch the color code from global vars and send it over to elements options

#

am I making sense now?

covert oasis
#

yes! I didn't even know this was a thing in CSS so I was struggling to help.

We can ignore the error part entirely then right? Mostly you could force for example colorPrimary to your variable and confirm it just doesn't work?
Just want to make sure I understand the question fully and then I'll chase down an answer

hot barn
#

yep

covert oasis
#

Can I ask you to write a really basic CSS rule with your global var and then pass it to primaryColor so I see what you want to do?

hot barn
#

const options: StripeElementsOptions = {
mode: 'payment',
amount: 20000,
currency: 'eur',
appearance: {
theme: 'stripe',
variables: {
colorPrimary: 'var(--color-blue-dark)',
},

#

in browser it says --color-blue-dark is undefined

covert oasis
#

ack and that var(...) works fine in your normal CSS?

#

that's the part I've never seen before

hot barn
#

yes

#

can you add someone who might be aware of it?

covert oasis
#

yep I'm asking internally. I'm fairly confident we don't support this as we're extremely strict with the subset of CSS rules that work but I'm asking now that I get the question!

hot barn
#

oki

covert oasis
hot barn
#

hmmm so it's possible that's for sure

covert oasis
#

yeah trying to make sense of that example for now

#

okay making some progress now

#
  theme: 'stripe',
  variables: {
    colorDanger: '#FF0000',
  },
  rules: {
    '.Input': {
      border: '1px solid var(--colorDanger)',
    },
  }
},```
#

this works, this uses the variable --colorDanger from the top one

#

I don't think we support your own arbitrary global variables though, does that make sense?

#

and yeah okay one of the engineers working on the product confirmed that it's not possible to have "arbitrary variables" today unfortunately

hot barn
#

oki

covert oasis
#
const options = {
  clientSecret: '<?= $intent->client_secret ?>',
  appearance: {
    theme: 'stripe',
    variables: {
      colorDanger: '#FF0000',
    },
    rules: {
      '.Input': {
        border: `1px solid ${colorBorder}`,
      },
      '.Input::placeholder': {
        color: 'var(--colorDanger)',
      },
    }
  },
};```
#

This is the closest they came up with that might work for you. You can see colorBorder is a JS variable that is referenced with the ${colorBorder} and var(--colorDanger) is from the variables inside the apperance and both work