how to change infoWindow Style in react-google-maps reactjs [duplicate] - reactjs

This question already has answers here:
Styling Google Maps InfoWindow
(8 answers)
Closed 2 years ago.
I want to change the style of infowindow:
creat a CSS file to change .gm-style .gm-style-iw-d and .gm-style .gm-style-iw-c proprty but nothing to chnage , i wnat to change or disable max-width ,over-flow:scroll , padding-right,... like this pic :
and i read this link: InfoWindowOptions and write this line for change maxWidth :
<InfoWindow options={{maxWidth:300}} onCloseClick={() => togelOpenCloseInfoWindos}>
but nothing to change.
and this is my code:
{isOpen &&
<InfoWindow options={{ maxWidth: 300 }} style={{ backgroundColor: 'red' }} onCloseClick={() => togelOpenCloseInfoWindos}>
<Grid container style={{ paddingLeft: 8, paddingRight: 8, }} xs={12} spacing={0} >
<Grid item xs={7} sm={8} zeroMinWidth>
<Typography noWrap component="p">
<Box fontWeight="bold">
{props.MyProps.locations.NICKNAME}</Box>
</Typography>
{/* <p className={classes.card_title}>{car.NICKNAME}</p> */}
</Grid>
<Grid item xs={5}>{speed_logo(props.MyProps.locations)}</Grid>
<Grid item xs={7} style={{ marginTop: -9 }}><p className={classes.card_time}>{timeToShow(props.MyProps.locations.SENTDATE)}</p></Grid>
<Grid item xs={5} style={{ marginTop: -9 }}>{tempture_logo(props.MyProps.locations)}</Grid>
<Grid xs={12}><Typography component='p' className={classes.card_Address}>{props.MyProps.locations.POSDESCRIPTION}</Typography></Grid> </Grid>
</InfoWindow>
}
please help me to change style of infoWindow

I'm not sure how to change your InfoWindow via element.style{} in the CSS file however I successfully override these values when I put it inside the .gm-style .gm-style-iw-c {} on the CSS file and appending !important on each line, like the following code:
.gm-style .gm-style-iw-c {
padding-right: 10px !important;
padding-bottom: 0px !important;
max-width: 500px !important;
max-height: 326px !important;
min-width: 0px !important;
position: absolute;
box-sizing: border-box;
overflow: hidden;
top: 0;
left: 0;
transform: translate(-50%,-100%);
background-color: #dd9191;
border-radius: 8px;
box-shadow: 0 2px 7px 1px rgba(0,0,0,0.3);
}
Note: This might be what you are looking for, however it is possible that class names will be changed by Google Maps Platform in the future.
As for the maxWidth options in the InfoWindow, I tried using it in my reactjs code without overriding it in my CSS file and it worked properly. Here is how it looks like in my code:
<InfoWindow onCloseClick={this.props.handleCloseCall} options= {{maxWidth : 100 }}>
<span>This is InfoWindow message!</span>
</InfoWindow>
Note: You need to change the YOUR_API_KEY_HERE string with your own API key in the index.js of the code provided for it to work properly.
Hope this helps!

Related

Canvas doesn't match Modal with AntD

I have created a Modal in which I add a Canvas from Recat Three Fiber.
The documentation says that Canvas should fill the parent's space.
To show it well, I added a yellow color to the Canvas parent as you can see in the picture.
However, Canvas doesn't want to fill that space.
The important thing is that when I change the size of the browser minimally, it works immediately.
Do I have something not defined in this way?
<Modal bodyStyle={{ height: "500px" }}>
<Content>
<Canvas
style={{
width: "100%",
height: "100%",
}}
>
<color attach="background" args={["skyblue"]} />
</Canvas>
</Content>
</Modal>;
const Content = styled.div`
width: 100%;
height: 100%;
background: yellow;
`;
IMAGE

Customise popover material-ui shape

I am using popover and currently, it is a plain rectangle which sits right below the box. I want to add small triangles like a pointer to make it nicer to look at and maybe add margin or padding-top so it will sit a bit lower from the box, just like this.
This is how I called the popover
<Grid item xs={12} sm={3} ref={divToRef}>
<Box pl={2} pt={1}>
<Typography className={classes.weight} variant="caption" color="textSecondary">
{t('search to').toUpperCase()}
</Typography>
</Box>
<Box pl={1}>
<AutoCompleteInput //some codes here />
</Box>
<Popover id="tofield" open={openTo} anchorEl={divToRef.current} onClose={handleClose} anchorOrigin={{
vertical: 'bottom',
horizontal: 'center',
}} transformOrigin={{
vertical: 'top',
horizontal: 'center',
}}>
<Typography className={classes.popoverText}>
Please enter destination
</Typography>
</Popover>
</Grid>
and I used withStyles to modify the paper
const Popover = withStyles((theme) => ({
root: {},
paper: {
backgroundColor: '#e02020',
boxShadow: '0 20px 15px -20px rgba(0, 0, 0, 0.15)',
borderRadius: theme.spacing(1),
padding: theme.spacing(2),
},
}))(MuiPopover)
How can I add the small triangle and adjust the position of transformOrigin (maybe add padding/margin) of the popover?
You can do this with adding this to the CSS:
.tooltip-top::before {
content: '';
position: absolute;
display: block;
width: 0px;
left: 50%;
top: 0;
border: 15px solid transparent;
border-top: 0;
border-bottom: 15px solid #5494db;
transform: translate(-50%, calc(-100% - 5px));
}
You can play around with those fields to customize where you want the arrow to be, how wide you want it and how tall you want the arrow. Check out this CodePen

React Stripe Elements - set width to auto for iFrame? Elements invisible inside grid and modal

I am trying to build a Stripe form using React Elements, inside of a React Modal, with layout managed by React Grid
<StripeProvider apiKey="stripeApiKey">
<Grid
container
direction="column"
alignItems="center"
justify="center"
style={{ minWidth: '30rem', maxWidth: '100rem' }}
>
<Grid item>
<Grid
container
direction="column"
justify="center"
style={{
backgroundColor: theme.palette.primary.dark,
padding: '73px',
width: '100%'
}}
>
<Elements>
<CardElement />
</Elements>
</Grid>
</Grid>
</Grid>
</StripeProvider>
The above renders the CardElement, but it's set to 1px width. If I manually set the IFrame's width property to auto it completely resolves my problem. How can I set the IFrame's width property for Stripe? (or is this even possible with cross-origin IFrame)
Or if not, how else can I resolve this issue to get the fields to display?
The style for individual elements for React-Stripe has to be passed manually as props. Below is an example from their official react-stripe-elements sample:
Elements
<CardNumberElement
onBlur={handleBlur}
onChange={this.handleChange}
onFocus={handleFocus}
onReady={handleReady}
{...createOptions(this.props.fontSize)}
/>
Function createOptions
const createOptions = (fontSize, padding) => {
return {
style: {
base: {
fontSize,
color: '#424770',
letterSpacing: '0.025em',
fontFamily: 'Source Code Pro, monospace',
'::placeholder': {
color: '#aab7c4',
},
...(padding ? { padding } : {}),
},
invalid: {
color: '#9e2146',
},
},
};
};
css
input,
.StripeElement {
display: block;
margin: 10px 0 20px 0;
max-width: 500px;
padding: 10px 14px;
font-size: 1em;
font-family: 'Source Code Pro', monospace;
box-shadow: rgba(50, 50, 93, 0.14902) 0px 1px 3px, rgba(0, 0, 0, 0.0196078) 0px 1px 0px;
border: 0;
outline: 0;
border-radius: 4px;
background: white;
}

How I can change the color of the text of Ant Design TabPane?

I use a Tabs with some TabPane in my code but the text stay always in Blue, I want to change it to grey.
I try several things but none fuction.
I try:
this for apply the text color with the parent:
<Tabs style={{ height: "fit-content",font: "#363636" }} >
and
<Tabs style={{ height: "fit-content",color: "#363636" }} >
this for each the children :
<TabPane tab={t("tabPanelGeneral/name")} key="1" style={{ color: "#363636" }}>
and
<TabPane tab={t("tabPanelGeneral/name")} key="1" style={{ font: "#363636" }}>
Putting it here if someone still needs it
You can use tabBarStyle prop to add custom css. source
To change the color of the active tab, You need to update color of the button:
.ant-tabs-tab.ant-tabs-tab-active .ant-tabs-tab-btn {
color: #363636 !important;
font-weight: 500;
}
To change the color of the blue bottom bar:
.ant-tabs-ink-bar {
position: absolute;
background: #000000;
pointer-events: none;
}
if you change the color of the tab text then put CSS like this
demo codesandbox link you view demo
.ant-tabs-tab {
color: #363636 !important;
}
.ant-tabs-tab-active {
color: #363636 !important;
}
You can set
.ant-tabs-ink-bar {
background: none;
}
And use a custom-tab
.custom-tab{
height : fit-content;
color:#363636;
}
You can apply css for your active tab.
.ant-tabs-nav .ant-tabs-tab-active {
color: '#363636';
}
you simply can add classNames to your components and add their styles on your style sheet :
<Tabs className="custom-tab" >
and the style sheet :
.custom-tab{
height : fit-content;
color:#363636;
}

ReactJS + MaterialUI: SelectField height change

I'm using React material-ui SelectField on my page. I'm not able to adjust the height of the select field. Here is my code snippet:
<SelectField
underlineStyle={{
display: 'none'
}}
style={{
width: '49%',
padding: '0 0 5em 5em',
border: '1px solid #ccc',
borderRadius: '5px',
backgroundColor: '#fff',
margin: '16px 0px 0px 28px',
}}
floatingLabelText="Select Stack*"
value={this.state.stack}
onChange={this.handleStackChange.bind(this)}
>
{this.state.dropDownStack}
</SelectField>
My UI is looking as below
I need to reduce the height of dropdown box, how can I do it?
You have to set it using following:
<SelectField
className="custom-selectfield"
underlineStyle={{
visibility: 'hidden',
}}
floatingLabelStyle={{
top: '14px',
}}
style={{
border: '1px solid #ccc',
height: '45px',
}}
floatingLabelText="Select Stack*"
value={this.state.stack}
onChange={this.handleStackChange.bind(this)}>
{this.state.dropDownStack}
</SelectField>
There is some internal CSS applied in material UI so in order to overwrite it added a custom class to SelectPicker component named custom-selectfield
Add following lines in your CSS file
.custom-selectfield > div:nth-child(2) {
margin-top: -6px !important;
}

Resources