Stripe payment select styling - css

I'm trying to style the stripe dropdown select to match bootstrap's select. here is my html
<form id="payment-form">
<div class="form-row">
<div>
<label for="bank-element">
Bank
</label>
<div id="bank-element">
<!-- A Stripe Element will be inserted here. -->
</div>
</div>
</div>
<button id="button" data-secret="<?= $intent->client_secret ?>">
Submit Payment
</button>
<!-- Used to display form errors. -->
<div id="error-message" role="alert"></div>
</form>
in my js file i have this
var style = {
base: {
'padding': "10px 12px",
'color': '#495057',
'fontFamily': 'apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif',
'border-color': '#80BDFF',
'outline':'0',
'box-shadow': '0 0 0 .2rem rgba(0,123,255,.25)',
'transition': 'border-color .15s ease-in-out, box-shadow .15s ease-in-out'
},
invalid: {
color: "#fa755a"
}
};
var Bank = elements.create(
'Bank',
{style: style, accountHolderType: 'individual'}
);
id="bank-element" is there the dropdown select is. Anyone know how to do this? or that I'm missing. Thank you

Great question, but unfortunately you're limited to the style options listed here:
https://stripe.com/docs/js/appendix/style
This means that you won't be able to set: border-color, transition, border-color, or outline on the element itself. You can apply a border & animations to the container div, but you won't be able to set up the animation transition on anything inside the Element.

Related

How to do an ease in transition after a react if statement

I'm trying to create a catalogue which has a filter component. Once the filter button is clicked, it triggers a variable to turn true which then switches what is being shown on the screen. I want to know how I can make this switch smooth and ease in using css. Here is my code:
<div>
{this.state.showProjects === true &&
<div className="test">
{this.state.projects && this.state.projects.map((project) => (
<ProjectDetails key={project._id} project={project}/>
))}
</div>
}
{this.state.showProjects === false &&
<div className="initial-screen">
Enter filter options to get started!
</div>
}
</div>
Where and how should I incorporate the css ease property?
If I'm understanding what your ask is, you can implement a class-based solution that has your transition effects in there.
<div>
<div className=`test content ${this.state.showProjects && 'active'}`>
{this.state.projects && this.state.projects.map((project) => (
<ProjectDetails key={project._id} project={project}/>
))}
</div>
<div className=`initial-screen content ${!this.state.showProjects && 'active'}`>
Enter filter options to get started!
</div>
</div>
I added another class called content which would have the main transition styling that you would need for your animations. The active class would be your identifier as to what is currently being displayed.
.content {
opacity: 0;
transition-duraction: 2s;
transition-timing-function: ease;
&.active {
opacity: 100;
}
}
This would just add a simple fade-in/fade-out, but you can use this at a simple template for you to use to start adding in more styling; like movement.

Override components CSS once modal button is pressed?

I've currently got a modal set up, where once it's pressed, it opens a component of mine up. However, this component has a fixed css (which I want to keep), but when the modal is pressed, I want that CSS to change. Is this possible ? I've looked at a few things but can't seem to find something that works. What I've got currently can be seen below, and it doesn't override the original css.
const [currentModal, openModal] = useState(null);
const [appState, changeChange] = useState({
activeObject: null,
objects: [{id: 1}]
in the return
<div className="modal">
{currentModal === 'modal1' ?
<MyComponent>
</MyComponent>
: null}
<div class="class1">
{appState.objects.map((elements,index) => (
<button key={index} classnName="box active"
onClick={() => openModal('modal1')}>
<Modal1></Modal1>
</button>
))}
</div>
The CSS
.box{
width:200px;
height:200px;
margin:10px;
transition: background-color 0.1s ease-in-out;
}
.inactive{
background-color:pink;
}
.active {
background-color: blue;
width:200px;
height:200px;
margin:10px;
}
Use styled components: https://styled-components.com/docs/basics#adapting-based-on-props
Just pass a prop to the styled component wrapping your model. this prop will indicate if the modal has been pressed or not.
You'll have to change the css according to the prop value.

Vue transitioned element not showing after transition is complete

I'm trying to animate an element to full browser height when the user clicks on the top bar. The animation works, but once the (enter) animation is finished the container jumps back to zero height, while it's supposed to stay until the user clicks the close button.
How do I make the container stay 100vh when the animation is finished?
I tried adding height: 100vh; on the element, but by doing that the transition animation stopped working. (by removing the height, the animation works but the element disappears)
Not sure if it matters, but I changed v-if into v-show and also added a key on the container, but that didn't seem to make a difference.
Here's a link to my code. And to view the animation.
<!-- AboutMeComponent.vue -->
<template>
<div>
<div v-show="!extended" class="small-container" #click="extended = !extended">
<h4>
CLICK ME
</h4>
</div>
<ExtendTransition>
<div v-show="extended" key="1" class="main-container">
<div class="icon-container">
<a v-show="extended" href="#" #click="extended = !extended">
<font-awesome-icon icon="times"/>
</a>
</div>
</div>
</ExtendTransition>
</div>
</template>
<!-- ExtendTransition.vue -->
<template>
<transition appear name="extend" mode="out-in">
<slot></slot>
</transition>
</template>
<style lang="scss">
.extend-enter-active,
.extend-leave-active {
transition: 3s;
}
.extend-enter-to,
.extend-leave {
height: 100vh;
}
.extend-leave-to {
height: calc(20px + 1vw);
}
.extend-enter {
height: calc(40px + 3vw);
}
</style>
A transition only is applied while the transition is playing. Once the transition finished, all transition classes are removed. This means that your element must have the CSS you want it to have after the transition is finished. You can then use the transition classes to set the initial state and define the transition to get to that point, and from that point to the initial state.
The easiest way to solve this problem is by making ExtendTransition.vue the only component that worries about the transition, and using a wrapper that wraps the thing you want to extend.
<template>
<transition appear name="extend" mode="out-in">
<div class="extend-transition-wrapper" v-show="extended">
<slot></slot>
</div>
</transition>
</template>
<script>
export default {
props: {
extended: {
type: Boolean,
default: false
}
}
};
</script>
The only thing you then have to do is to set the default state of your wrapper:
.extend-transition-wrapper {
height: 100vh;
will-change: height;
position: relative;
}
In your ABoutMeComponent.vue you then use a prop to show and hide the content:
<ExtendTransition :extended="extended">
<div class="main-container">
<div class="icon-container">
<a v-show="extended" href="#" #click="extended = !extended">
<font-awesome-icon icon="times"/>
</a>
</div>
</div>
</ExtendTransition>
And finally you set .main-container to always have a height of 100%. Since we set the wrapper to have position: relative, this will force the main container to become the height of that element.

How to use ng-animate to add slide effect on menu

I am trying to implement a slide effect using ng-animate and CSS styles, but can't figure out what's wrong with my code...
Can I do this using values in percentages for min-height and max-height? I cant use fixed values in px.
JSFIDDLE
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app>
Click to toggle menu
<div class="menu" ng-show="collapsed" ng-animate="{show: 'menu-show', hide: 'menu-hide'}">
<div class="files">
<input type="checkbox" />
<label>first</label>
<input type="checkbox" />
<label>second</label>
</div>
<div class="diffs">
<input type="checkbox" />
<label>first</label>
<input type="checkbox" />
<label>second</label>
</div>
</div>
</div>
CSS:
.menu-show-setup, .menu-hide-setup {
transition:all 0.5s ease-out;
overflow:hidden
}
.menu-show-setup {
max-height:0;
}
.menu-show-setup.menu-show-start {
max-height:25%;
}
.menu-hide-setup {
max-height:25%;
}
.menu-hide-setup.menu-hide-start {
max-height:0;
}
First ensure you have angular and angular-animate loaded.
The CDN for angular-animate is ...
<script src="//ajax.googleapis.com/ajax/libs/angularjs/X.Y.Z/angular-animate.js"></script>
Then you need to reference the animations that ngAnimate gives ...
https://docs.angularjs.org/api/ngAnimate
For example, ng-if when switched from false to true will add the class .fade AND .ng-enter to the element on which the ng-if is located. These classes will be automatically removed after a short time. ngAnimate does this for you.
What you HAVE to do is to style what these classes do ...
example:
.fade.ng-enter {
transition:0.5s linear all;
opacity:0;
}
/* The finishing CSS styles for the enter animation */
.fade.ng-enter.ng-enter-active {
opacity:1;
}
now ng-animate will animate from .fade.ng-enter to .fade.ng-enter.ng-enter-active
if you do not define these styles ng-animate will do nothing.
You will see classes being added and remove by ng-animate if you inspect the relevant element in your browser's develop tools. If you cannot see these classes being added and removed then something is wrong with your loading of angular or ng-animate.

How can I build a CSS selector that will highlight/outline a focused tab, while not effecting other non-tab widgets?

PROBLEM:
The user is able to utilize the "tab" key to navigate thru the page and land on the "tabs" panel. However, when they initially land on the "tabs" panel - there is no visual indication (outline/highlight/etc) that they are there.
-As a result, they think their tab key (or the tab panel) is not working correctly.
Notes:
My suspicion is that this new behavior is due to a CSS change that occurred when upgrading from 1.8.x to 1.10.x - But, of course, I'm not sure.
I've tried various css entries to cause the focused tab to visually outline/highlight...-So far, one that appears to have a visual effect on the tab is this selector:
.ui-widget :focus
{
border-style: inset !important;
border-width: 5px !important;
}
...But, this selector is too broad and impacts other widgets on the page that are outside of the tabs() DIV. --I only want to "highlight" focused tabs within the "tabs" DIV.
Question:
How can I build a CSS selector that will highlight/outline a focused tab, while not effecting other non-tab widgets?
(Thanks for your help)
jquery script
$(document).ready(function() {
$('#tabdiv').tabs(); //<== tabs
$( "input[type=submit], a, button" ).button().click(function( event ) {event.preventDefault();});
$( "#datepicker" ).datepicker();
});
css
.ui-widget :focus
{
border-style: inset !important;
border-width: 3px !important;
}
HTML snippet
<div>
<h1>body-A</h1>
<div id="tabdiv">
<ul>
<li>TabA</li>
<li>TabB</li>
<li>TabC</li>
<li>TabD</li>
</ul>
<div id="tabA">
<div>
<span>tabA stuff</span>
</div>
</div>
<div id="tabB">
<div>
<span>tabB stuff</span>
</div>
</div>
<div id="tabC">
<div>
<span>tabC stuff</span>
</div>
</div>
<div id="tabD">
<div>
<span>tabD stuff</span>
</div>
</div>
</div>
<div>
<p>Date: <input type="text" id="datepicker" /></p>
<button>A button element</button>
<input type="submit" value="A submit button" />
An anchor
</div>
</div>
You could use the following selector
[id~=tab]:focus
It appears that to following works...
.ui-widget#tabdiv :focus
{
border-style: inset !important;
border-width: 3px !important;
}
Thanks!

Resources