How to right align a search bar - html

how to right align the search bar ? I've tried everything nothing seems to work. I want the 'Transaction' title on the left of the card and search bar on the right of the card
this is my code
export default function ContactsCard(Rows) {
return (
<Card sx={{ minWidth: 900, minHeight: 1, }}>
<CardContent>
<Stack direction="row" alignItems="center" gap={1}>
<RuleIcon sx={{ color: "text.secondary" }} />
<Typography sx={{ fontSize: 16, fontWeight: 'bold' }} textAlign='start' color="text.secondary" gutterBottom>
Transactions
</Typography>
<SearchBar rows={rows} />
</Stack>
<DataGridHelper title='Contact' rows={Rows} columns={columns} />
</CardContent>
</Card>
);
}
this how my table looks like now

Try adding a wrapper to the icon and typography with display="flex" flexDirection="column" and justifyContent="space-between" in Stack
export default function ContactsCard(Rows) {
return (
<Card sx={{ minWidth: 900, minHeight: 1, }}>
<CardContent>
<Stack direction="row" alignItems="center" justifyContent="space-between" gap={1}>
<Box display="flex" flexDirection="column">
<RuleIcon sx={{ color: "text.secondary" }} />
<Typography sx={{ fontSize: 16, fontWeight: 'bold' }} textAlign='start' color="text.secondary" gutterBottom>
Transactions
</Typography>
</Box>
<SearchBar rows={rows} />
</Stack>
<DataGridHelper title='Contact' rows={Rows} columns={columns} />
</CardContent>
</Card>
);
}

Related

Reactjs Material UI Table component causes grid to expand

I have a Table component that is nested in a Grid component and I would like the Grid component to remain in its width when my Table component is rendered. My current code causes the Grid component to expand but I'm not sure how to prevent this? I'm pretty stuck :/
Before rendering the Table component when it has not received data:
After rendering the Table component when it received data:
Here are my codes from parent to child
Mainpage
return (
<Box>
<Box sx={{display: "grid", alignItems: "center", justifyContent: "center", paddingTop: "40px"}}>
<Typography variant="h4">Some Header</Typography>
</Box>
<Box sx={{display: "grid", alignItems: "center", justifyContent: "center", paddingTop: "30px"}}>
<Wallet></Wallet>
</Box>
<Box sx={{display: "grid", alignItems: "center", justifyContent: "center", paddingTop: "40px"}}>
<Typography variant="h5">Some Other Header</Typography>
</Box>
<Box sx={{display: "grid", alignItems: "center", justifyContent: "center", paddingTop: "10px"}}>
<Cmc></Cmc>
</Box>
</Box>
)
Wallet
return (
<Box>
<Grid container rowSpacing={2} sx={{paddingInline: "25px"}} width={"100%"}>
<Grid item xs={12}>
<Queryfield text={fields.staking} onFunction={getStakingAmounts}/>
<Stakingfield resData={resData.stakingRes}/>
</Grid>
<Grid item xs={12}>
<Queryfield text={fields.outstandingWithdrawals} onFunction={getOutstandingWithdrawals}/>
<Outstandingfield/>
</Grid>
<Grid item xs={12}>
<Queryfield text={fields.withdrawnAmounts} onFunction={getWithdrawnAmount}/>
<Withdrawnfield/>
</Grid>
</Grid>
</Box>
)
Queryfield
return (
<Box>
<Typography sx={{ paddingLeft: "0px" }}>{txt}</Typography>
<Box sx={{display: "inline-flex", width: "100%"}}>
<TextField onChange={handleQueryChange} label="Enter Address" fullWidth type="search" variant="filled" size="small" />
<Button variant="outlined" onClick={handleQuery}>Send</Button>
</Box>
</Box>
)
Stakingfield
const renderTable = () => {
if (stakingRes !== "") {
return (
<TableContainer component={Paper}>
<Table size="small">
<TableHead>
<TableRow>
<TableCell>Validator Address</TableCell>
<TableCell>Delegated Amount</TableCell>
<TableCell>Token</TableCell>
<TableCell>Shares</TableCell>
</TableRow>
</TableHead>
<TableBody>
{stakingRes.map((row, index) => (
<TableRow key={index}>
<TableCell component="th" scope="row">{row.validatorAddress}</TableCell>
<TableCell>{Number(row.delegatedAmount) / 10**18}</TableCell>
<TableCell>{row.denom}</TableCell>
<TableCell>{Number(row.shares) / 10**18}</TableCell>
</TableRow>
))}
</TableBody>
</Table>
</TableContainer>
);
}
else {
return (
<div></div>
)
}
}
return (
<Box>
{renderTable()}
</Box>
)
I solved the issue.
For anyone wondering, the Table component in Material UI is not responsive. I used a DataGrid and it all worked out.

How can I use 100% of screen height in Next.js using ant design?

currently I am creating project for my customer, where I have to use React (Next.js) with Ant desing. Everything is new for me so I am reading a lot and trying to figure it myself.
Currently I have problem with height of my web page. I created Layout component, which contain Navbar, Footer components created by me and { children }. That children is coming from _app.js, code bellow.
<>
<Layout>
<Component {...pageProps} />
</Layout>
</>
As you can see on pictures bellow, Navbar and Footer is correcly placed on screen. Problem is with Content between. As show on photo 1, I have some free space between content and footer. Also, photo 2 is from another monitor and there I don't even have whole content.
Photo 1: Photo of free space between footer and content
Photo 2: photo of monitor when I don't have whole content
Here is my whole HomeScreen code:
export default function Home() {
return (
<>
<Layout>
<Content style={{ marginTop: '80px' }}>
<Row>
<Col xs={24} sm={24} md={24} lg={9} xl={9} xxl={9}>
<Carousel autoplay>
<Image src='/landing-images/desktop/watts-rising-tree-dedication-slide-1.jpg' preview={false} />
<Image src='/landing-images/desktop/watts-rising-tree-dedication-slide-2.jpg' preview={false} />
<Image src='/landing-images/desktop/watts-rising-tree-dedication-slide-3.jpg' preview={false} />
<Image src='/landing-images/desktop/watts-rising-tree-dedication-slide-4.jpg' preview={false} />
<Image src='/landing-images/desktop/watts-rising-tree-dedication-slide-5.jpg' preview={false} />
<Image src='/landing-images/desktop/watts-rising-tree-dedication-slide-6.jpg' preview={false} />
</Carousel>
</Col>
<Col xs={24} sm={24} md={24} lg={10} xl={10} xxl={10} style={{ backgroundColor: '#017A4E', borderRight: '1px solid white', borderLeft: '1px solid white' }}>
<Row type="flex" justify="center" align="middle" style={{marginLeft: '20px'}}>
<Col style={{ inlineSize: '600px' }}>
<p style={{ fontSize: '60px', fontWeight: 400, lineHeight: '70px', color: 'white', marginTop: '50px' }}>
Watts Rising Invites You to Dedicate a Tree in the Watts Community
</p>
</Col>
</Row>
<Row type="flex" justify="start" align="middle" style={{marginLeft: '20px'}}>
<Row style={{ marginTop: '-32px'}}>
<Col xs={24} sm={24} md={24} lg={3} xl={3} xxl={3} style={{ inlineSize: '400px' }}></Col>
<Col xs={24} sm={24} md={24} lg={21} xl={21} xxl={16} style={{ inlineSize: '320px' }}>
<p style={{ fontSize: '22px', fontWeight: 400, lineHeight: '32px', color: 'white' }}>
This site is intended to tell stories, remember, celebrate and care
for the people and community we hold dearest in Watts by naming and growing big,
beautiful trees in their honor. We welcome you to vidis This
Living History and encourage you even more to partcipitate!
</p>
</Col>
</Row>
</Row>
<Row type="flex" justify="start" align="middle" style={{marginLeft: '20px', marginTop: '40px'}}>
<Row>
<Col xs={24} sm={24} md={24} lg={3} xl={3} xxl={3} style={{ inlineSize: '400px' }}></Col>
<Col xs={24} sm={24} md={24} lg={21} xl={21} xxl={16} style={{ inlineSize: '320px' }}>
<Button size='large' block={true} style={{ color: '#017A4E' }}>Create New Tree Dedication</Button>
<br />
<br />
<Link href='/map'><Button size='large' block={true} style={{ color: '#017A4E' }}>View All Tree Dedications</Button></Link>
<br />
<br />
<Button type='text' size='large' block={true} style={{ marginLeft: '-38px', fontSize: '20px' }}><span style={{ textDecoration: 'underline', color: 'white' }}>Already have an account? Login</span></Button>
</Col>
</Row>
</Row>
</Col>
<Col xs={24} sm={24} md={24} lg={5} xl={5} xxl={5}>
<Col justify="center" xs={24} sm={24} md={24} lg={20} xl={20} xxl={20}>
<div style={{ marginTop: '32px', marginLeft: '24px', marginRight: '24px' }}>
<Col>
<Image src='/square-tree-icon.svg' preview={false} width={40} />
<br />
<br />
<span style={{ color: '#017A4E', fontSize: '20px', fontWeight: '600', lineHeight: '24px' }}>Dedicate Tree</span>
<br />
<br />
<span style={{ fontSize: '18px', fontWeight: '400', lineHeight: '40px' }}>Dedicate a tree in Watts in the name of someone you love, admire, or want to celebrate. </span>
</Col>
<br />
<br />
<Col>
<Image src='/water-icon.svg' preview={false} width={40} />
<br />
<br />
<span style={{ color: '#017A4E', fontSize: '20px', fontWeight: '600', lineHeight: '24px' }}>Care for yur tree</span>
<br />
<br />
<span style={{ fontSize: '18px', fontWeight: '400', lineHeight: '40px' }}>Help nurture a tree to reveal how time, care, and effort can greatly impact the growth and longevity of these beautiful plants.</span>
</Col>
<br />
<br />
<Col>
<Image src='/people-icon.png' preview={false} width={40} />
<br />
<br />
<span style={{ color: '#017A4E', fontSize: '20px', fontWeight: '600', lineHeight: '24px' }}>Care for your community</span>
<br />
<br />
<span style={{ fontSize: '18px', fontWeight: '400', lineHeight: '40px' }}>These trees will positively impact the environment and the health and well being of the Watts community for generations to come.</span>
</Col>
</div>
</Col>
</Col>
</Row>
</Content>
</Layout>
</>
)
}
Here is my Navbar code:
import { Layout } from 'antd';
const { Header } = Layout;
const Navbar = () => {
return (
<>
<Header style={{
width: '100%',
backgroundColor: '#017A4E',
height: '80px',
borderBottom: '1px solid white',
position: 'fixed',
zIndex: 1
}}>
<Row>
<Col>
<Row>
<Link href="/"><Image style={{ cursor: 'pointer', marginTop: '10px' }} src='/tree-dedication-logo.png' preview={false} width={60} /></Link>
<Link href="/"><Image style={{ cursor: 'pointer', marginTop: '18px' }} src='/logo-text.png' preview={false} width={220} /></Link>
</Row>
</Col>
<Space />
<Col style={{ marginLeft: 'auto' }}>
<Button type='default' size={'large'} style={{ color: '#017A4E', marginRight: '15px', marginTop: '20px' }}> Make Tree Dedication </Button>
<Dropdown overlay={menu} trigger='click'>
<Button onClick={toggleCollapsed} size='large' type='default' style={{ color: 'white', backgroundColor: '#017A4E' }}>
<Space>
Marek Žáčik
{collapsed ? <CaretUpOutlined /> : <CaretDownOutlined />}
</Space>
</Button>
</Dropdown>
</Col>
</Row>
</Header>
</>
)
}
export default Navbar;
And here is Footer code:
import { Layout } from 'antd';
const { Footer } = Layout;
const AppFooter = () => {
return (
<>
<Footer style={{
borderTop: '1px solid white',
position: 'fixed',
left: 0,
bottom: 0,
width: '100%',
height: '60px',
backgroundColor: '#FFFFFF',
textAlign: 'center',
alignItems: 'center',
display: 'flex',
}}
>
<Col>
<h4 style={{ marginLeft: '14px' }}>© Watt Rising. All rights reserved.</h4>
</Col>
<Col style={{ marginLeft: 'auto', marginRight: '10px' }}>
<Link href='/privacy-policy'><Button size='large' type='text'><span style={{ textDecoration: 'underline' }}>Privacy Policy</span></Button></Link>
<Link href='/terms-of-service'><Button size='large' type='text'><span style={{ textDecoration: 'underline' }}>Terms of Service</span></Button></Link>
</Col>
</Footer>
</>
)
}
export default AppFooter;
Am I doing it completely wrong? Sorry, I am really new to this and I tried to google it but found nothing that could help me.
Thanks

Nav bar opens all menus simultaneously upon clicking

This code snippet is my nav bar for an admin user. The intended behavior is that there are 3 icons (navigation menu, user menu, and manage button icons). The issue is that the drop down items from each of these icons all display when clicking on any of the icons. The intended behavior is to get each dropdown menu to display the selected information for that given icon.
function NavbarAdmin() {
const classes = navbarStyle();
const [anchorEl, setAnchorEl] = React.useState(null);
const isMenuOpen = Boolean(anchorEl);
const handleProfileMenuOpen = (event) => {
setAnchorEl(event.currentTarget);
};
const handleNavMenuOpen = (event) => {
setAnchorEl(event.currentTarget);
};
const handleManageMenuOpen = (event) => {
setAnchorEl(event.currentTarget);
};
const handleMenuClose = () => {
setAnchorEl(null);
};
const userMenu = (
<Menu
anchorEl={anchorEl}
anchorOrigin={{ vertical: 'top', horizontal: 'left' }}
keepMounted
transformOrigin={{ vertical: 'top', horizontal: 'left' }}
open={isMenuOpen}
onClose={handleMenuClose}
>
<MenuItem onClick={handleMenuClose}>Profile</MenuItem>
<MenuItem onClick={handleMenuClose}>My account</MenuItem>
<MenuItem onClick={handleMenuClose}>Sign Out</MenuItem>
</Menu>
);
const navMenu = (
<Menu
anchorEl={anchorEl}
anchorOrigin={{ vertical: 'top', horizontal: 'right' }}
keepMounted
transformOrigin={{ vertical: 'top', horizontal: 'right' }}
open={isMenuOpen}
onClose={handleMenuClose}
>
<MenuItem onClick={handleMenuClose}>Home</MenuItem>
<MenuItem onClick={handleMenuClose}>Movies</MenuItem>
<MenuItem onClick={handleMenuClose}>Concessions</MenuItem>
<MenuItem onClick={handleMenuClose}>Showtimes</MenuItem>
</Menu>
);
const manageMenu = (
<Menu
anchorEl={anchorEl}
anchorOrigin={{ vertical: 'top', horizontal: 'right' }}
keepMounted
transformOrigin={{ vertical: 'top', horizontal: 'right' }}
open={isMenuOpen}
onClose={handleMenuClose}
>
<MenuItem onClick={handleMenuClose}>Movies</MenuItem>
<MenuItem onClick={handleMenuClose}>Seats</MenuItem>
<MenuItem onClick={handleMenuClose}>Test</MenuItem>
<MenuItem onClick={handleMenuClose}>Test</MenuItem>
<MenuItem onClick={handleMenuClose}>Test</MenuItem>
<MenuItem onClick={handleMenuClose}>Test</MenuItem>
</Menu>
);
return (
<div className={classes.grow}>
<AppBar position="static">
<Toolbar>
<IconButton
edge="start" className={classes.menuButton}
color="inherit"
aria-label="nav account"
aria-haspopup="true"
onClick={handleNavMenuOpen}
color="inherit"
>
<MenuIcon />
</IconButton>
<Typography className={classes.acptheater} variant="h6" noWrap>
ACP Theater
</Typography>
<div className={classes.grow} />
<div>
<IconButton aria-label="show messages" color="inherit">
<Badge badgeContent={1} color="secondary">
<MailIcon />
</Badge>
</IconButton>
<IconButton
edge="end" className={classes.menuButton}
aria-label="user account"
aria-haspopup="true"
onClick={handleProfileMenuOpen}
color="inherit"
>
<AccountCircle />
</IconButton>
<Button
edge="end" className={classes.menuButton}
aria-label="user account"
aria-haspopup="true"
onClick={handleManageMenuOpen}
color="inherit"color="inherit"
>
Manage</Button>
<Button color="inherit">Login</Button>
</div>
</Toolbar>
</AppBar>
{manageMenu}
{navMenu}
{userMenu}
</div>
);
}
All three <Menu...s have anchorEl={anchorEl} - so whatever is set on state setAnchorEl() will match all three.
Those <Menu parameters should be hard-coded with the desired match value.
Example:
const handleProfileMenuOpen = (event) => {
setAnchorEl('menuProfile');
};
...
const userMenu = (
<Menu
anchorEl={'menuProfile'} <== this is the important one... right now all 3 are set to whatever was just clicked
function NavbarAdmin() {
const classes = navbarStyle();
const [anchorEl1, setAnchorEl1] = React.useState(null);
const [anchorEl2, setAnchorEl2] = React.useState(null);
const [anchorEl3, setAnchorEl3] = React.useState(null);
const isNavMenuOpen = Boolean(anchorEl1);
const isProfileMenuOpen = Boolean(anchorEl2);
const isManageMenuOpen = Boolean(anchorEl3);
const handleNavMenuOpen = (event) => {
setAnchorEl1(event.currentTarget);
}
const handleProfileMenuOpen = (event) => {
setAnchorEl2(event.currentTarget);
};
const handleManageMenuOpen = (event) => {
setAnchorEl3(event.currentTarget);
};
const handleNavMenuClose = () => {
setAnchorEl1(null);
};
const handleProfileMenuClose = () => {
setAnchorEl2(null);
};
const handleManageMenuClose = () => {
setAnchorEl3(null);
};
const navMenu = (
<Menu
anchorEl={anchorEl1}
anchorOrigin={{ vertical: 'top', horizontal: 'left' }}
keepMounted
transformOrigin={{ vertical: 'top', horizontal: 'left' }}
open={isNavMenuOpen}
onClose={handleNavMenuClose}
>
<MenuItem onClick={handleNavMenuClose}>Home</MenuItem>
<MenuItem onClick={handleNavMenuClose}>Movies</MenuItem>
<MenuItem onClick={handleNavMenuClose}>Concessions</MenuItem>
<MenuItem onClick={handleNavMenuClose}>Showtimes</MenuItem>
</Menu>
)
const userMenu = (
<Menu
anchorEl={anchorEl2}
anchorOrigin={{ vertical: 'top', horizontal: 'right' }}
keepMounted
transformOrigin={{ vertical: 'top', horizontal: 'right' }}
open={isProfileMenuOpen}
onClose={handleProfileMenuClose}
>
<MenuItem onClick={handleProfileMenuClose}>Profile</MenuItem>
<MenuItem onClick={handleProfileMenuClose}>My account</MenuItem>
<MenuItem onClick={handleProfileMenuClose}>Sign Out</MenuItem>
</Menu>
);
const manageMenu = (
<Menu
anchorEl={anchorEl3}
anchorOrigin={{ vertical: 'top', horizontal: 'right' }}
keepMounted
transformOrigin={{ vertical: 'top', horizontal: 'right' }}
open={isManageMenuOpen}
onClose={handleManageMenuClose}
>
<MenuItem onClick={handleManageMenuClose}>Movies</MenuItem>
<MenuItem onClick={handleManageMenuClose}>Seats</MenuItem>
</Menu>
);

How to render components side by side

I have the following output:
And this is the code in the render method:
return (
<div>
<div>
<TextMedium fontSize="15px" text="Number" />
<Select options={[{ label: 'AreaCode', value: 'AreaCode' }]} />
</div>
<div>
<TInput placeholder={daytimePhoneNumber} />
</div>
</div>
);
It composes of custom components. I am trying to style them so that they are all side by side and that the TextMedium component should take half the space and the remaining space should be split equally between the two components.. essentially 50% to TextMedium, 25% to both Select and TInput.
I tried styling it but nothing seems to be working.
you can use bootstrap for layout alignment or styling the outer div {display:flex; flex-direction:row;},
return (
<div style={display:flex; flex-direction:row;}>
<div>
<TextMedium fontSize="15px" text="Number" />
<Select options={[{ label: 'AreaCode', value: 'AreaCode' }]} />
</div>
<div>
<TInput placeholder={daytimePhoneNumber} />
</div>
</div>
);
Use flex layout, like this:
return (
<Container
style={{
display: 'flex'
}}>
<Text
style={{
width: '50%'
}}
/>
<Select
style={{
width: '25%'
}}
/>
<Input
style={{
width: '25%'
}}
/>
</Container>
);
You can use display: 'flex' and flexDirection: 'row' CSS options to display the divs in row. Here is the sample code for displaying controls in row.
<div style={{
display: 'flex',
flexDirection: 'row',
width: '100%',
backgroundColor: 'lightGrey',
}}>
<div style={{ width: '50%' }}>
<label style={{width: '100%'}}>Number</label>
</div>
<div style={{ width: '25%' }}>
<select style={{width: '100%'}}>
<option value="AreaCode">AreaCode</option>
</select>
</div>
<div style={{ width: '25%' }}>
<input style={{width: '100%'}} type="text" value="2343434" />
</div>
</div>
Working codesandbox here

Create <div> of Custom shapes to design RFM segmentation

So RFM segmentation looks like this https://www.putler.com/wp-content/uploads/2017/05/rfm-grid.png
I want to recreate it in html where each blocks repesents one segment. I tried doing it as [1,1] block but as I want to create a hover effect. Mutiple blocks need to be combined together to have one overall effect.
I tried doing it with div but not able to create the hover effect
https://i.imgur.com/S51lu0p.png
Here is the React code
<div class="rfmBox">
<div class="flex-container">
<div>5</div>
<div style={{ backgroundColor: "#FFC9CE" }} />
<div style={{ backgroundColor: "#FFEDB7" }} />
<div style={{ backgroundColor: "#E7F7BA" }} />
<div style={{ backgroundColor: "#E7F7BA" }} />
<div style={{ backgroundColor: "#E0ECBC" }} />
</div>
<div class="flex-container">
<div>4</div>
<div style={{ backgroundColor: "#FFEDB7" }} />
<div style={{ backgroundColor: "#FFEDB7" }} />
<div style={{ backgroundColor: "#E7F7BA" }} />
<div style={{ backgroundColor: "#E7F7BA" }} />
<div style={{ backgroundColor: "#E7F7BA" }} />
</div>
<div class="flex-container">
<div>3</div>
<div style={{ backgroundColor: "#FFEDB7" }} />
<div style={{ backgroundColor: "#FFEDB7" }} />
<div style={{ backgroundColor: "#9AF4E7" }} />
<div style={{ backgroundColor: "#C1FFFA" }} />
<div style={{ backgroundColor: "#C1FFFA" }} />
</div>
<div class="flex-container">
<div>2</div>
<div style={{ backgroundColor: "#CFD8E4" }} />
<div style={{ backgroundColor: "#F1F2F4" }} />
<div style={{ backgroundColor: "#B9E0E7" }} />
<div style={{ backgroundColor: "#C1FFFA" }} />
<div style={{ backgroundColor: "#C1FFFA" }} />
</div>
<div class="flex-container">
<div>1</div>
<div style={{ backgroundColor: "#CFD8E4" }} />
<div style={{ backgroundColor: "#CFD8E4" }} />
<div style={{ backgroundColor: "#B9E0E7" }} />
<div style={{ backgroundColor: "#C0ECFD" }} />
<div style={{ backgroundColor: "#FFEEEE" }} />
</div>
<div class="flex-container">
<div />
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
</div>
</div>
With display: grid; you can create only one <div> by area, and then for each area place it as you wish using grid-column and grid-row css properties.
Just add some position: relative and z-index and that's it !
I made a codepen where I tried to do the same thing that what you want : https://codepen.io/loic/pen/ZZePXd
(I did setup any React code, as I solved your issue with only html and css).
Hope it made the trick ;)
I think what you need is to add position: relative; on the divs and a z-index on hover.
here is a code sandbox that functions similar but is totally ugly.
https://codesandbox.io/embed/oqwlvr7229?fontsize=14
EDIT: Read your issue wrong. here is an update. similar solution but reflects your problem closer.
https://codesandbox.io/embed/oqwlvr7229?fontsize=14