Skip to main content

use hooks - useTheme in Material UI

contactPage.js
import { useTheme } from '@material-ui/core/styles'
const useStyles = makeStyles(styles)

export default function ContactList () {
const theme = useTheme()
...
<TableCell>
<strong style={{ color: theme.palette.primary.main }}>
{name}
</strong>
index.js
import { ThemeProvider } from '@material-ui/styles'
import { createMuiTheme } from '@material-ui/core/styles'
import { green, orange, red, blue } from '@material-ui/core/colors'

const theme = createMuiTheme({
palette: {
primary: blue,
secondary: orange
},
status: {
danger: red
}
})
...

ReactDOM.render(
<ApolloProvider client={client}>
<StateProvider>
<ThemeProvider theme={theme}>
<Router history={hist}>
<Switch>
<PublicRoute exact path='/login' component={LoginPage} />
<PrivateRoute path='/admin' component={Admin} />
<Redirect from='/' to='/admin/dashboard' />
</Switch>
</Router>
</ThemeProvider>
</StateProvider>
</ApolloProvider>,
document.getElementById('root')
)
admin.js
const [color, setColor] = React.useState('blue')
<Sidebar
routes={routes}
logoText={'OCCopier'}
logo={logo}
image={image}
handleDrawerToggle={handleDrawerToggle}
open={mobileOpen}
color={color}
{...rest}
/>
material-dashboard-react.js
const primaryColor = ['#ed701b', '#ed701b', '#ed701b', '#ed701b']
const warningColor = ['#ff9800', '#ffa726', '#fb8c00', '#ffa21a']
sidebarStyle.js

blue: {
backgroundColor: primaryColor[0],
boxShadow:
'0 12px 20px -10px rgba(' +
hexToRgb(infoColor[0]) +
',.28), 0 4px 20px 0 rgba(' +
hexToRgb(blackColor) +
',.12), 0 7px 8px -5px rgba(' +
hexToRgb(infoColor[0]) +
',.2)',
'&:hover,&:focus': {
backgroundColor: primaryColor[0],
boxShadow:
'0 12px 20px -10px rgba(' +
hexToRgb(infoColor[0]) +
',.28), 0 4px 20px 0 rgba(' +
hexToRgb(blackColor) +
',.12), 0 7px 8px -5px rgba(' +
hexToRgb(infoColor[0]) +
',.2)'
}
},

Comments

Popular posts from this blog

About GraphQL - Downside

Web caching complexity

File uploading. Since GraphQL doesn’t understand files, a file uploading feature is not included in its specification. You won’t have to deal with this limitation in case of REST, as there you can POST or PUT whatever content you want to.
To allow file uploads in your GraphQL web app, there are several options: using Base64 encoding. But it will make the request larger and expensive to encode/decode.making a separate API endpoint just for this purpose.using a library like Apollo for implementing the GraphQL multipart request specification.uploadFileToS3:combineResolvers( // isAuthenticated, async (parent, args, { models }) => { const { file } = awaitargs const { createReadStream, filename, mimetype, encoding } = awaitfile conststream = createReadStream() constresult = awaituploadFileToS3(filename, stream) returnresult } ),