MuiTabPanl-Root Padding remove using CSS or Mui Styles? - reactjs

I want to override the MUI Tab Panel Padding. I override the .MuiTabPanel-Root Class globally and inline style. But, the Tab Panel is not override. Screenshot and Code Below attached.
I want to remove the padding from the MuiTabPanel-Root class padding.
When I applied the padding as 0px in "MuiTabPanel-Root" class is not working.
But, When I remove the padding from this class .css-13xfq8m-MuiTabPanel-root Tab panel padding was removed. I don't know how to override the "TabPanel-root padding" using react js
CSS Global :
.MuiTabPanel-root{
padding: 0px;
}
CSS Inline :
<TabPanel value="1" classes={{
"& .MuiTabPanel-root": {
padding: "0px",
},
}}>
Full Code Tab Component :
import * as React from 'react';
import Box from '#mui/material/Box';
import Tab from '#mui/material/Tab';
import TabContext from '#mui/lab/TabContext';
import TabList from '#mui/lab/TabList';
import TabPanel from '#mui/lab/TabPanel';
import HistoryTable from '../HistoryTable/HistoryTable';
import { Button } from '#mui/material';
import SampleTable from './SampleTable';
import './TradeTab.css';
import { MuiThemeProvider, createTheme } from "#material-ui/core/styles";
import { orange, pink, green } from "#material-ui/core/colors";
export default function SampleTabControl() {
const theme = createTheme({
overrides: {
MuiTabs: {
indicator: {
backgroundColor: 'red'
}
},
MuiTab: {
root: {
"&:hover": {
backgroundColor: pink[100],
color: pink[700]
},
".MuiTabPanel-root":{
padding:0
}
},
selected: {
backgroundColor: orange[100],
color: orange[700],
"&:hover": {
backgroundColor: 'green',
color: green[700]
}
}
}
}
});
const [value, setValue] = React.useState('1');
const handleChange = (event, newValue) => {
setValue(newValue);
};
return (
<MuiThemeProvider theme={theme}>
<Box sx={{ width: '100%', typography: 'body1'}}>
<TabContext value={value}>
<Box sx={{ borderBottom: 1, borderColor: 'divider' }}>
<TabList onChange={handleChange} aria-label="lab API tabs example">
<Tab label="Item One" value="1" style={{color: "white", fontWeight:"500"}}
sx={{backgroundColor: value=="1" ? "blue" : "lightgrey" }}/>
<Tab label="Item Two" value="2" style={{color: "white", fontWeight:"500", marginLeft:'10px'}}
sx={{backgroundColor: value=="2" ? "blue" : "lightgrey"}}/>
<Button variant='outlined' style={{marginLeft:'100px', size:'small', height:'30px', marginTop:"10px"}}>1X</Button>
</TabList>
</Box>
<TabPanel value="1" classes={{
"& .MuiTabPanel-root": {
padding: "0px",
},
}}>
<SampleTable/>
</TabPanel>
<TabPanel value="2">Item Two</TabPanel>
<TabPanel value="3">Item Three</TabPanel>
</TabContext>
</Box>
</MuiThemeProvider>
);
}
Full Code Table :
import React, { useMemo } from 'react';
import MaterialReactTable from 'material-react-table';
import { makeStyles } from '#mui/styles';
//nested data is ok, see accessorKeys in ColumnDef below
const data = [
{
name: {
firstName: 'John',
lastName: 'Doe',
},
address: '261 Erdman Ford',
city: 'East Daphne',
state: 'Kentucky',
},
{
name: {
firstName: 'Jane',
lastName: 'Doe',
},
address: '769 Dominic Grove',
city: 'Columbus',
state: 'Ohio',
},
{
name: {
firstName: 'Joe',
lastName: 'Doe',
},
address: '566 Brakus Inlet',
city: 'South Linda',
state: 'West Virginia',
},
{
name: {
firstName: 'Kevin',
lastName: 'Vandy',
},
address: '722 Emie Stream',
city: 'Lincoln',
state: 'Nebraska',
},
{
name: {
firstName: 'Joshua',
lastName: 'Rolluffs',
},
address: '32188 Larkin Turnpike',
city: 'Charleston',
state: 'South Carolina',
},
];
const SampleTable = () => {
//should be memoized or stable
const columns = useMemo(
() => [
{
accessorKey: 'name.firstName', //access nested data with dot notation
header: 'First Name',
},
{
accessorKey: 'name.lastName',
header: 'Last Name',
},
{
accessorKey: 'address', //normal accessorKey
header: 'Address',
},
{
accessorKey: 'city',
header: 'City',
},
{
accessorKey: 'state',
header: 'State',
},
],
[],
);
return <MaterialReactTable columns={columns} data={data} style={{padding:'0px'}}/>;
};
export default SampleTable;
I try to remove the padding for "MuiTabPanel-root".
Expected Result :
Remove the padding from "MuiTabPanel-Root"

Related

Material Table rowStyle background color change based on cell value in

I am trying to have the color of the row change colors based on the priority number. For example, if the priority is 4 the color of the entire row should be blue. The problem is that I'm unsure of how to achieve this. I know Material Table assigns ID's to the rows, but I have no way of accessing them. Below is what I have come up with so far. I need options[backgroundColor] to be set based on the priority number. I have a codesandbox here as well https://codesandbox.io/s/notifications-material-ui-spq45
import React from "react";
import { Container } from "react-bootstrap";
import MaterialTable from "material-table";
import FilterListIcon from "#material-ui/icons/FilterList";
import SearchIcon from "#material-ui/icons/Search";
import FirstPage from "#material-ui/icons/FirstPage";
import LastPage from "#material-ui/icons/LastPage";
import ChevronLeft from "#material-ui/icons/ChevronLeft";
import ChevronRight from "#material-ui/icons/ChevronRight";
import CloseIcon from "#material-ui/icons/Close";
function App() {
//loop through the array of priority numbers, and display color based on number
function colors(num) {
for(let i = 0; i < num.length; i++) {
if (num[i] === 4) {
options.rowStyle.backgroundColor = "blue";
}
if (num[i] === 3) {
options.rowStyle.backgroundColor = "red";
}
console.log(num[i]);
}
}
let data = [
{
date: "06-29-2021",
subject: "CANBUS LOSS, Automatic Reboot!",
message:
"SCMs CANBUS LOSS for more than 15 min, Automatic System Reboot!",
category: "System",
priority: 4,
error: "SYS0080"
},
{
date: "06-28-2021",
subject: "Reboot!",
message: "Automatic System Reboot!",
category: "Alarm",
priority: 3,
error: "SYS0090"
},
{
date: "06-25-2021",
subject: "Testing!",
message: "Generator not running!",
category: "Generator",
priority: 2,
error: "SYS0050"
}
];
let columns = [
{ title: "Date", field: "date" },
{ title: "Subject", field: "subject" },
{ title: "Message", field: "message" },
{ title: "Category", field: "category" },
{ title: "Priority Level", field: "priority" },
{ title: "Error Code", field: "error" }
];
let options = {
filtering: false,
sorting: true,
rowStyle: {
fontFamily: "Mulish-Regular",
backgroundColor: ""
},
headerStyle: {
fontFamily: "Mulish-Regular",
fontSize: "1.1em",
fontWeight: "600",
backgroundColor: "#D1D1D8"
},
searchFieldStyle: {
fontFamily: "Mulish-Regular"
}
};
// Loop through all the data and find the priority number, and put it in an array
let map = data.map((x) => x.priority);
console.log(map);
colors(map);
return (
<>
<Container>
<MaterialTable
title=""
columns={columns}
data={data}
options={options}
icons={{
Filter: (props) => <FilterListIcon style={{ fill: "#2D3155 " }} />,
Search: (props) => <SearchIcon style={{ fill: "#2D3155 " }} />,
FirstPage: (props) => <FirstPage style={{ fill: "#2D3155 " }} />,
LastPage: (props) => <LastPage style={{ fill: "#2D3155 " }} />,
NextPage: (props) => <ChevronRight style={{ fill: "#2D3155 " }} />,
PreviousPage: (props) => (
<ChevronLeft style={{ fill: "#2D3155 " }} />
),
SortArrow: (props) => (
<FilterListIcon
style={{ fill: "#2D3155 ", fontSize: "1.4em", margin: ".4em" }}
/>
),
ResetSearch: (props) => <CloseIcon style={{ fill: "#2D3155 " }} />
}}
/>
</Container>
</>
);
}
export default App;
As you can read in the docs, rowStyle accepts an object or a function.
Hence, you can set rowStyle using a function that receives rowData as parameter, an example:
const rowBackgroundColors = {
"2": "yellow", // just for example, remove it if you don't need
"3": "orange",
"4": "red",
};
const options = {
// ...
rowStyle: (rowData) => {
return {
fontFamily: "Mulish-Regular",
backgroundColor: rowBackgroundColors[rowData.priority] ?? "#fff",
};
},
// ...
};

Data driven Tabs with Material UI React

I want to render Tabs & Tabpanels with the data array which I got.
I have rendered the Tab headings but I couldn't render the Tabpanel data when the Tabs are clicked. Following is my code.
I want to show the theaters for each date if the date Tab is selected.
I have tried many but failed. Appreciate your suggestions.
Thanks...
import React from "react";
import PropTypes from "prop-types";
import { makeStyles } from "#material-ui/core/styles";
import AppBar from "#material-ui/core/AppBar";
import Tabs from "#material-ui/core/Tabs";
import Tab from "#material-ui/core/Tab";
import PhoneIcon from "#material-ui/icons/Phone";
import FavoriteIcon from "#material-ui/icons/Favorite";
import PersonPinIcon from "#material-ui/icons/PersonPin";
import HelpIcon from "#material-ui/icons/Help";
import ShoppingBasket from "#material-ui/icons/ShoppingBasket";
import ThumbDown from "#material-ui/icons/ThumbDown";
import ThumbUp from "#material-ui/icons/ThumbUp";
import Typography from "#material-ui/core/Typography";
import Box from "#material-ui/core/Box";
import { DateRangeSharp } from "#material-ui/icons";
const DATES = [
{
id: 1,
day: "WED",
date: 19,
theater: [{ tname: "vista" }, { tname: "liberty" }],
},
{
id: 2,
day: "THU",
date: 20,
theater: [{ tname: "PVR" }, { tname: "CCC" }],
},
{
id: 3,
day: "FRI",
date: 21,
theater: [{ tname: "vista" }, { tname: "liberty" }],
},
{ id: 4, day: "SAT", date: 22 },
{ id: 5, day: "SUN", date: 23 },
{ id: 6, day: "MON", date: 24 },
{ id: 7, day: "TUE", date: 25 },
{ id: 8, day: "WED", date: 26 },
];
function TabPanel(props) {
const { children, value, index, ...other } = props;
return (
<div
role="tabpanel"
hidden={value !== index}
id={`scrollable-force-tabpanel-${index}`}
aria-labelledby={`scrollable-force-tab-${index}`}
{...other}
>
{value === index && (
<Box p={3}>
<Typography>{children}</Typography>
</Box>
)}
</div>
);
}
TabPanel.propTypes = {
children: PropTypes.node,
index: PropTypes.any.isRequired,
value: PropTypes.any.isRequired,
};
function a11yProps(index) {
return {
id: `scrollable-force-tab-${index}`,
"aria-controls": `scrollable-force-tabpanel-${index}`,
};
}
const useStyles = makeStyles((theme) => ({
root: {
flexGrow: 1,
width: "100%",
backgroundColor: theme.palette.background.paper,
},
}));
export default function ScrollableTabsButtonForce() {
const classes = useStyles();
const [value, setValue] = React.useState(0);
const handleChange = (event, newValue) => {
setValue(newValue);
};
return (
<div className={classes.root}>
<AppBar
position="static"
style={{ background: "#333545", minHeight: 60 }}
>
<Tabs
value={value}
onChange={handleChange}
variant="scrollable"
scrollButtons="on"
indicatorColor="secondary"
textColor="primary"
aria-label="scrollable force tabs example"
style={{ minHeight: 60 }}
wrapped
>
{DATES.map((showtdates) => {
return (
<Tab
label={showtdates.date + " " + showtdates.day}
{...a11yProps(0)}
style={{ color: "#fff", fontSize: 20, minHeight: 60 }}
/>
);
})}
</Tabs>
</AppBar>
<TabPanel value={value} index={0}>
showtdates.theater
</TabPanel>
</div>
);
}
For each day in your DATES array you have to create a TabPanel and pass the index and value as prop. You can easily do this by mapping over your DATES array. Inside your map function, you can access all properties and display the theaters.
As an example, I used the List component of material-ui to list the theaters.
This could then look like this:
import React from "react";
import PropTypes from "prop-types";
import { makeStyles } from "#material-ui/core/styles";
import AppBar from "#material-ui/core/AppBar";
import Tabs from "#material-ui/core/Tabs";
import Tab from "#material-ui/core/Tab";
import PhoneIcon from "#material-ui/icons/Phone";
import FavoriteIcon from "#material-ui/icons/Favorite";
import PersonPinIcon from "#material-ui/icons/PersonPin";
import HelpIcon from "#material-ui/icons/Help";
import ShoppingBasket from "#material-ui/icons/ShoppingBasket";
import ThumbDown from "#material-ui/icons/ThumbDown";
import ThumbUp from "#material-ui/icons/ThumbUp";
import Typography from "#material-ui/core/Typography";
import Box from "#material-ui/core/Box";
import { DateRangeSharp } from "#material-ui/icons";
import { List, ListItem, ListItemText } from "#material-ui/core";
const DATES = [
{
id: 1,
day: "WED",
date: 19,
theater: [{ tname: "vista" }, { tname: "liberty" }]
},
{
id: 2,
day: "THU",
date: 20,
theater: [{ tname: "PVR" }, { tname: "CCC" }]
},
{
id: 3,
day: "FRI",
date: 21,
theater: [{ tname: "vista" }, { tname: "liberty" }]
},
{ id: 4, day: "SAT", date: 22 },
{ id: 5, day: "SUN", date: 23 },
{ id: 6, day: "MON", date: 24 },
{ id: 7, day: "TUE", date: 25 },
{ id: 8, day: "WED", date: 26 }
];
function TabPanel(props) {
const { children, value, index, ...other } = props;
return (
<div
role="tabpanel"
hidden={value !== index}
id={`scrollable-force-tabpanel-${index}`}
aria-labelledby={`scrollable-force-tab-${index}`}
{...other}
>
{value === index && (
<Box p={3}>
<Typography>{children}</Typography>
</Box>
)}
</div>
);
}
TabPanel.propTypes = {
children: PropTypes.node,
index: PropTypes.any.isRequired,
value: PropTypes.any.isRequired
};
function a11yProps(index) {
return {
id: `scrollable-force-tab-${index}`,
"aria-controls": `scrollable-force-tabpanel-${index}`
};
}
const useStyles = makeStyles((theme) => ({
root: {
flexGrow: 1,
width: "100%",
backgroundColor: theme.palette.background.paper
}
}));
export default function App() {
const classes = useStyles();
const [value, setValue] = React.useState(0);
const handleChange = (event, newValue) => {
setValue(newValue);
};
return (
<div className={classes.root}>
<AppBar
position="static"
style={{ background: "#333545", minHeight: 60 }}
>
<Tabs
value={value}
onChange={handleChange}
variant="scrollable"
scrollButtons="on"
indicatorColor="secondary"
textColor="primary"
aria-label="scrollable force tabs example"
style={{ minHeight: 60 }}
wrapped
>
{DATES.map((showtdates) => {
return (
<Tab
label={showtdates.date + " " + showtdates.day}
{...a11yProps(0)}
style={{ color: "#fff", fontSize: 20, minHeight: 60 }}
/>
);
})}
</Tabs>
</AppBar>
{/* map over dates and create TabPanel */}
{DATES.map((date, idx) => {
// check if theater property exists and create a list of theaters as an example
const theaters = date.hasOwnProperty('theater')
? date.theater.map((theater) => (
<ListItem>
<ListItemText primary="Theater name" secondary={theater.tname} />
</ListItem>
))
: null;
return (
<TabPanel value={value} index={idx}>
<List>{theaters}</List>
</TabPanel>
);
})}
</div>
);
}
Live demo:

I want to show Multiselect options in simple text in reactjs using react-select

I want to show all of my options in simple text like "firstOption,secOption". I am using react-select. but i couldn't find any solution.
Here's my code
import React from 'react';
import CreatableSelect from 'react-select/creatable';
const PersonalDetails =()=>{
const [selectedbusiness,setselectedbusiness] = useState([]);
const businessChange = (selectedbusiness) => {
setselectedbusiness(selectedbusiness);
}
const businessType = [
{ label: "Retailers", value: "Retailers" },
{ label: "Health Practioners", value: "Health Practioners" },
{ label: "Distributors", value: "Distributors" },
{ label: "Food Service", value: "Food Service" },
{ label: "Manufacturers", value: "Manufacturers" },
{ label: "Business Service", value: "Business Service" },
{ label: "Investor", value: "Investor" },
{ label: "Blogging", value: "Blogging" },
];
return(
<>
<CreatableSelect
options={ businessType }
className="form__field form-control"
isMulti
onChange={businessChange}
styles={{ singleValue: (base) => ({ ...base, padding: 5, borderRadius: 5, background: selectedbusiness.value, color: 'white', display: 'flex' }) }}
defaultValue={ selectedbusiness }
name="selectedbusiness"
closeMenuOnSelect={false}
placeholder="Select Business Type"
/>
</>
)
}
const showOptions = () => {
const formattedOptions = selectedbusiness.map(business => business.label).join(',');
// printing the options to the console
console.log(formattedOptions);
}
you can iterate through selectedbusiness and get their label and use the join method to create a formatted options string.
return(
<>
<CreatableSelect
options={ businessType }
className="form__field form-control"
isMulti
onChange={businessChange}
styles={{ singleValue: (base) => ({ ...base, padding: 5, borderRadius: 5, background: selectedbusiness.value, color: 'white', display: 'flex' }) }}
defaultValue={ selectedbusiness }
name="selectedbusiness"
closeMenuOnSelect={false}
placeholder="Select Business Type"
/>
<button type="button" onClick={showOptions}>Show options</button>
</>
)

How to add "plus-button" on top right in material-table for react and call my specific function in react

This is my code:
import React, { useState, useEffect } from 'react';
import { Fade } from "#material-ui/core";
import MaterialTable from 'material-table';
import { makeStyles } from '#material-ui/core/styles';
import './styles.css';
const useStyles = makeStyles(theme => ({
root: {
flexGrow: 1,
width: '70%',
margin: 'auto',
marginTop: 20,
boxShadow: '0px 0px 8px 0px rgba(0,0,0,0.4)'
}
}));
function User(props) {
const classes = useStyles();
const [checked, setChecked] = React.useState(false);
useEffect(() => {
setChecked(prev => !prev);
}, [])
const [state, setState] = React.useState({
columns: [
{ title: 'name', field: 'name' },
{ title: 'Setor', field: 'sector' }
],
data: [
{ name: 'Tom Brady', setor: 'Quarterback'},
{ name: 'Aaron Rodgers', setor: 'Quarterback'},
{ name: 'Ryan Tannehill', setor: 'Quarterback'},
{ name: 'Julian Edelman', setor: 'Wide Receiver'},
{ name: 'Julio Jones', setor: 'Wide Receiver'},
{ name: 'Marcus Mariota', setor: 'Quarterback'},
{ name: 'Patrick Mahomes', setor: 'Quarterback'},
{ name: 'Antonio Brown', setor: 'Wide Receiver'},
{ name: 'Eli Manning', setor: 'Quarterback'},
{ name: 'Antonio Brown', setor: 'Wide Receiver'},
{ name: 'Mike Evans', setor: 'Wide Receiver'},
{ name: 'Russel Wilson', setor: 'Quarterback'},
{ name: 'Drew Brees', setor: 'Quarterback'},
{ name: 'Cam Newton', setor: 'Quarterback'}
],
actions: [
{ icon: 'create', tooltip: 'Edit', onClick: (event, rowData) => alert('Edit ' + rowData.name + '?')},
{ icon: 'lock', tooltip: 'Block', onClick: (event, rowData) => alert('Block ' + rowData.name + '?')},
{ icon: 'delete', tooltip: 'Delete', onClick: (event, rowData) => alert('Delete ' + rowData.name + '?')}
],
options: {
headerStyle: { color: 'rgba(0, 0, 0, 0.54)' },
actionsColumnIndex: -1,
exportButton: true,
paging: true,
pageSize: 10,
pageSizeOptions: [],
paginationType: 'normal'
}
});
return (
<>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap" />
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons" />
<Fade in={checked} style={{ transitionDelay: checked ? '300ms' : '0ms' }}>
<div className={classes.root}>
<MaterialTable options={state.options} title="Users" columns={state.columns} data={state.data} actions={state.actions}></MaterialTable>
</div>
</Fade>
</>
);
}
export default User;
I wanna add this button:
If I follow the default code from here https://material-ui.com/pt/components/tables/, I must add this code:
editable={{
onRowAdd: newData =>
new Promise(resolve => {
setTimeout(() => {
resolve();
setState(prevState => {
const data = [...prevState.data];
data.push(newData);
return { ...prevState, data };
});
}, 600);
}),
But this code calls a specific function for material-table, I wanna call my own function, how can I add the previous button and call my own function?
My own function will open a modal with some inputs, more inputs than I show on table.
You can create custom actions
<MaterialTable
title="Editable Example"
columns={state.columns}
data={state.data}
actions={[
{
icon: "add_box",
tooltip: "my tooltip",
position: "toolbar",
onClick: () => {
console.log("clicked");
}
}
]}
/>
Working demo: https://codesandbox.io/s/material-demo-mgh26
You can override the toolbar, adding your custom button (or some other content!), as explained at https://stackoverflow.com/a/69854673/1288109 :
<MaterialTable
components={{
Toolbar: (props) => (
<div
style={{
display: "flex",
justifyContent: "flex-end",
alignItems: "center"
}}
>
<div style={{ width: "13rem" }}>
<MTableToolbar {...props} />
</div>
<Tooltip title="Add">
<IconButton>
<AddBox />
</IconButton>
</Tooltip>
</div>
),
}}
/>
You can use the position or isFreeAction property for having the action displayed there.
<MaterialTable
title="Editable Example"
columns={state.columns}
data={state.data}
actions={[
{
icon: "add_box",
tooltip: "my tooltip",
isFreeAction: true,
onClick: () => {
console.log("clicked");
}
}
]}
/>
The position parameter is more flexible providing different placements for the Button.
isFreeAction in the other hand accepts just a boolean for the action type.
Sandbox cloned from Mosh Feu https://codesandbox.io/s/material-demo-m8eug

React Router - How to route to a specific path within a loop

I am bit stuck and cannot find any similar issue.
In my application, I am looping over some data that I need to render but I am not sure how to use react-router in this case.
I would like to access to the project.pathname field in order to redirect to my Link.
But I am pretty sure its the wrong way.
All my routes are defined in my App.js file already but how to access this here ?
Here is my code snippet:
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import { Link } from 'react-router-dom'
import { withStyles } from '#material-ui/core/styles'
import Grid from '#material-ui/core/Grid'
import Typography from '#material-ui/core/Typography'
import Button from '#material-ui/core/Button'
// import Staces from '../assets/staces.png'
import SteffProject from '../assets/steffProject.jpg'
import AxtradeProject from '../assets/axtradeProject.jpg'
import HotspawtsProject from '../assets/hotspawtsProject.jpg'
import IbizaProject from '../assets/ibizaProject.jpg'
import CdaProject from '../assets/cdaProject.png'
const projectImages = [
{
img: CdaProject,
projectName: 'CARRE DARTISTES',
headline: 'Artist’s shop Back office ',
type: 'Web application',
id: 1,
pathname: '/AboutMe'
},
{
img: IbizaProject,
projectName: 'IBIZA',
headline: 'Accounting Platform ',
type: 'Web application',
id: 2,
pathname: '/Ibiza',
},
{
img: SteffProject,
projectName: 'STEFF',
headline: 'Deliveries Management',
type: 'Mobile application',
id: 3,
payhname: '/Steff',
},
{
img: HotspawtsProject,
projectName: 'HOTSPAWTS',
headline: 'Dog Sitting Platform ',
type: 'Mobile application',
id: 4,
pathname: '/Hotspawts',
},
{
img: AxtradeProject,
projectName: 'AXTRADE',
headline: 'Brokers platform ',
type: 'Web application',
id: 5,
pathname: '/Axtrade',
},
]
#withStyles((theme) => ({ // eslint-disable-line
projectPage: {
marginTop: 5,
backgroundColor: '#eee',
},
container: {
position: 'relative',
},
projectImage: {
width: '100%',
height: 'auto',
filter: 'grayscale(100%)',
},
title: {
color: '#fff',
position: 'absolute',
top: 20,
left: 10,
},
subheading: {
color: '#fff',
position: 'absolute',
top: 40,
left: 10,
},
caption: {
color: '#fff',
position: 'absolute',
top: 60,
left: 10,
},
display1: {
textAlign: 'center',
marginBottom: 20,
marginTop: 20,
},
raised: {
backgroundColor: '#424246',
marginTop: 10,
color: '#fff',
},
projectButton: {
position: 'absolute',
bottom: 10,
right: 10,
color: '#fff',
},
}))
export default class Projects extends Component {
static propTypes = {
classes: PropTypes.any.isRequired, // eslint-disable-line
}
render() {
const { classes } = this.props
return (
<Grid container className={classes.projectPage} alignItems="center" direction="column">
<Grid item>
<Typography className={classes.display1} variant="display1">Latest Projects</Typography>
</Grid>
<Grid item>
{projectImages.map(project => (
<div className={classes.container}>
<img
className={classes.projectImage}
key={project.id}
src={project.img}
alt={project.title}
/>
<Typography
className={classes.title}
variant="title"
>
{project.projectName}
</Typography>
<Typography className={classes.subheading} variant="subheading">{project.headline}</Typography>
<Typography className={classes.caption} variant="caption">{project.type}</Typography>
<Button className={classes.projectButton} component={Link} to={project.pathname}>project details</Button>
</div>
))}
</Grid>
<Grid item>
<Button className={classes.raised} size="medium" variant="raised">View more projects</Button>
</Grid>
</Grid>
)
}
}
You have typo in
{
img: SteffProject,
projectName: 'STEFF',
headline: 'Deliveries Management',
type: 'Mobile application',
id: 3,
payhname: '/Steff',
}
It should be pathname. I believe your code should work after fixing it.

Resources