Showing posts with label MAP FUNCTION. Show all posts
Showing posts with label MAP FUNCTION. Show all posts

Sunday, December 24, 2023

Json Decode in Div MAP Uses In LIST In BootStrap 5 REACTJS

December 24, 2023 0

 Json Decode in Div  MAP Uses In LIST In BootStrap 5 REACTJS


import React, { useState } from 'react';
import { useNavigate } from 'react-router-dom';

const Feature = () => {
    const navigate = useNavigate();

  const handlerSave = () => {
        console.log("Next Page");
        navigate('/features');
    }

    const jsonData = [
        {
            "name": "Raj",
            "age": 25,
            "city": "New York",
            "phone": "+91 5126548932"
        },
        {
            "name": "Avi",
            "age": 30,
            "city": "San Francisco",
            "phone": "+91 5126548932"
        },
        {
            "name": "Madhu",
            "age": 28,
            "city": "Los Angeles",
            "phone": "+91 5126548932"
        },
        {
            "name": "Nisha",
            "age": 22,
            "city": "Chicago",
            "phone": "+91 5126548932"
        }
    ];

    return (
        <div className="container-fluid border p-2 m-2 rounded-2 ">
            <h2 className=''>Features</h2>

            {/* Single Div */}
            <div className='d-flex flex-wrap gap-2 w-100'>
                {
                    // Json Data using map function
                    jsonData.map((data, index) => (
                        <div key={index} className='ps-5 flex-grow-1' style={{
                            backgroundColor: index % 2 === 0 ? 'yellow' : 'green',
                            maxWidth: '24%', flexBasis: '24%'
                        }}>
                            <div className='d-flex justify-content-between'>
                                <div className='pt-4'>
                                    <h2>{data.name}</h2>
                                    <h3>{data.city}</h3>
                                </div>
                                <div className=''>
                                    <div style={{ width: '100px', height: "100px", backgroundColor: "red" }}></div>
                                </div>
                            </div>
                            <div className='py-4'>
                                <h2>Age : {data.age}</h2>
                                <h3 style={{ fontWeight: 'bold' }}>Mobile No :- </h3>
                                <h2>{data.phone} </h2>

                            </div>
                        </div>
                    ))
                }
            </div>
        </div>
    );
}
export default Feature;

Div data (name , age) MAP uses in LIST in BootStrap 5 REACTJS

December 24, 2023 0

 Div data (name , age) MAP uses in LIST in BootStrap 5  REACTJS


Using-     

            index %2 == 0 ? 'yellow' : 'Green'


import React, { useState } from 'react';
import { useNavigate } from 'react-router-dom';

const Feature = () => {
    const navigate = useNavigate();
    const handlerSave = () => {
        console.log("Next Page");
        navigate('/features');
    }

    const names = ['Raj', 'Avi', 'Madhu', 'Nisha', 'Raj', 'Avi', 'Madhu', 'Nisha'];

    return (
        <div className="container-fluid border p-2 m-2 rounded-2 ">
            <h2 className=''>Features</h2>

            {/* Single Div */}
            <div className='d-flex flex-wrap gap-2 w-100'>
                {
                    names.map((data, index) => (
                        <div key={index} className='ps-5 flex-grow-1'
                            style={{
                                backgroundColor: index % 2 == 0 ? 'yellow' : 'green',
                                maxWidth: '24%', flexBasis: '24%'
                            }}>
                            <div className='d-flex justify-content-between ' >
                                <div className='pt-4'>
                                    <h2>{data}</h2>
                                    <h3>Text</h3>
                                </div>

                                <div className=''>
                                    <div style={{ width: '100px', height: "100px", backgroundColor: "red" }}></div>
                                </div>
                            </div>
                            <div className='py-4'>
                                <h2>Text : XXXXX </h2>
                                <h2>XT : XXXXX </h2>
                            </div>
                        </div>
                    ))
                }
            </div>
        </div>
    );
}
export default Feature;

Sunday, December 17, 2023

Button with Routes MAP use in List in MUI REACT JS

December 17, 2023 0

 Button with Routes MAP use in List in MUI REACT JS


// initilize list

const navItems = ['Home', 'About', 'Contact'];
const navRoutes = ['/' , '/login','/login'];


            <Box sx={{ display: { xs: 'none', sm: 'block' } }}>
                    // Decode with map Function
                 {navItems.map((item , index) => (
                    <Button key={item} href={navRoutes[index]} sx={{ color: '#fff' }}>
                        {item}
                    </Button>
                 ))}
             </Box>


Menu with Routes MAP use in List in MUI REACT JS

December 17, 2023 0

 Menu with Routes MAP use in List in MUI REACT JS


const navItems = ['Home', 'About', 'Contact'];
const navRoutes = ['/' , '/login','/login'];

function DrawerAppBar(props) {

    const handleDrawerToggle = () => {
        setMobileOpen((prevState) => !prevState);
    };

    const drawer = (
        <Box onClick={handleDrawerToggle} sx={{ textAlign: 'center' }}>
            <Typography variant="h6" sx={{ my: 2 }}>
                SUREVIH ROOM RENT
            </Typography>
         
            <List>
                    // Multiple map function decode
                    // Menu Items with Routes (Links)
                {navItems.map((item , index) => (
                    <ListItem key={item} disablePadding>
                        <ListItemButton  href={navRoutes[index]} sx={{ textAlign: 'center' }}>
                            <ListItemText primary={item} />
                        </ListItemButton>
                    </ListItem>
                ))}
            </List>
        </Box>
    );

    const container = window !== undefined ? () => window().document.body : undefined;

    return (

Single MAP use in List in MUI REACT JS

December 17, 2023 0

 Single MAP use in List in MUI REACT JS


const navItems = ['Home', 'About', 'Contact'];

function DrawerAppBar(props) {
    const drawer = (
        <Box onClick={handleDrawerToggle} sx={{ textAlign: 'center' }}>
       
            <List>
                    // Single map decode
                {navItems.map((item) => (
                    <ListItem key={item} disablePadding>
                        <ListItemButton sx={{ textAlign: 'center' }}>
                            <ListItemText primary={item} />
                        </ListItemButton>
                    </ListItem>
                ))}
            </List>

        </Box>
    );
}



export default DrawerAppBar;