Skip to content

Commit

Permalink
Fixed table content
Browse files Browse the repository at this point in the history
  • Loading branch information
putuadityabayu committed May 12, 2023
1 parent 415037d commit 2235df2
Show file tree
Hide file tree
Showing 8 changed files with 868 additions and 830 deletions.
768 changes: 386 additions & 382 deletions src/design/components/Parser.tsx

Large diffs are not rendered by default.

416 changes: 221 additions & 195 deletions src/design/components/TableContent.tsx

Large diffs are not rendered by default.

102 changes: 51 additions & 51 deletions src/design/hooks/useDarkTheme.ts
Original file line number Diff line number Diff line change
@@ -1,68 +1,68 @@
import {useCallback} from 'react'
import {useSelector,useDispatch} from '@redux/store'
import type {State} from '@type/redux'
import {Dispatch} from 'redux'
import { useCallback } from 'react'
import { useSelector, useDispatch } from '@redux/store'
import type { State } from '@type/redux'
import { Dispatch } from 'redux'
import useMediaQuery from '@mui/material/useMediaQuery';
import { getCookie, setCookie } from 'cookies-next';
import { getDayJs } from '@utils/main';
import { domainCookie } from '@src/config';

export default function useDarkTheme() {
const theme = useSelector<State['theme']>(s=>s.theme);
const theme = useSelector<State['theme']>(s => s.theme);
const dispatch = useDispatch();
const prefersDarkMode = useMediaQuery('(prefers-color-scheme: dark)');
const isDark=prefersDarkMode && theme==='auto'||theme==='dark';
const isDark = prefersDarkMode && theme === 'auto' || theme === 'dark';

const sendTheme=useCallback((val1:State['theme'],val2:State['redux_theme'])=>(dispatch: Dispatch)=>{
dispatch({type:"CHANGE_THEME",payload:val1})
dispatch({type:"REDUX_THEME",payload:val2})
},[])
const sendTheme = useCallback((val1: State['theme'], val2: State['redux_theme']) => (dispatch: Dispatch) => {
dispatch({ type: "CHANGE_THEME", payload: val1 })
dispatch({ type: "REDUX_THEME", payload: val2 })
}, [])

const setHighlightJs = useCallback((value: State['redux_theme'])=>{
const lightStyle = document.querySelector('link.higtlightjs-light');
const darkStyle = document.querySelector('link.higtlightjs-dark');
const setHighlightJs = useCallback((value: State['redux_theme']) => {
const lightStyle = document.querySelector('link.higtlightjs-light');
const darkStyle = document.querySelector('link.higtlightjs-dark');

if(value === 'light') {
darkStyle?.setAttribute('disabled','disabled');
lightStyle?.removeAttribute('disabled');
} else {
lightStyle?.setAttribute('disabled','disabled');
darkStyle?.removeAttribute('disabled');
}
},[])

const setTheme = useCallback((value: State['theme'],force?:boolean)=>{
const winDark = window?.matchMedia && window?.matchMedia('(prefers-color-scheme: dark)').matches;
const prefersDark = prefersDarkMode || winDark;
const newVal:State['redux_theme'] = (prefersDark && value=='auto')||value=='dark' ? 'dark' : 'light';
const kuki:State['theme'] = ['light','dark','auto'].indexOf(value) !== -1 ? value : 'auto';
if(force!==true) setCookie('theme',kuki,{expires:getDayJs().add(1,"year").toDate(),domain:domainCookie});
setHighlightJs(newVal)
// @ts-ignore
dispatch(sendTheme(kuki,newVal));
},[prefersDarkMode,dispatch,sendTheme,setHighlightJs])
if (value === 'light') {
darkStyle?.setAttribute('disabled', 'disabled');
lightStyle?.removeAttribute('disabled');
} else {
lightStyle?.setAttribute('disabled', 'disabled');
darkStyle?.removeAttribute('disabled');
}
}, [])

const checkTheme = useCallback(()=>{
const theme = getCookie('theme') as State['theme']|undefined;
let result = {
theme:"auto" as State["theme"],
redux_theme:"light" as State['redux_theme']
}
if(!theme || theme === 'auto') {
const setTheme = useCallback((value: State['theme'], force?: boolean) => {
const winDark = window?.matchMedia && window?.matchMedia('(prefers-color-scheme: dark)').matches;
const prefersDark = prefersDarkMode || winDark;
const redux_theme = prefersDark ? 'dark' : 'light'
result.redux_theme = redux_theme;
if(!theme) result.theme = redux_theme
else result.theme = theme;
} else {
result = {
theme,
redux_theme:theme
const newVal: State['redux_theme'] = (prefersDark && value == 'auto') || value == 'dark' ? 'dark' : 'light';
const kuki: State['theme'] = ['light', 'dark', 'auto'].indexOf(value) !== -1 ? value : 'auto';
if (force !== true) setCookie('theme', kuki, { expires: getDayJs().add(1, "year").toDate(), domain: domainCookie, sameSite: "lax" });
setHighlightJs(newVal)
// @ts-ignore
dispatch(sendTheme(kuki, newVal));
}, [prefersDarkMode, dispatch, sendTheme, setHighlightJs])

const checkTheme = useCallback(() => {
const theme = getCookie('theme') as State['theme'] | undefined;
let result = {
theme: "auto" as State["theme"],
redux_theme: "light" as State['redux_theme']
}
if (!theme || theme === 'auto') {
const winDark = window?.matchMedia && window?.matchMedia('(prefers-color-scheme: dark)').matches;
const prefersDark = prefersDarkMode || winDark;
const redux_theme = prefersDark ? 'dark' : 'light'
result.redux_theme = redux_theme;
if (!theme) result.theme = redux_theme
else result.theme = theme;
} else {
result = {
theme,
redux_theme: theme
}
}
}
return result;
},[prefersDarkMode])
return result;
}, [prefersDarkMode])

return {theme,isDark,setTheme,prefersDarkMode,checkTheme,setHighlightJs}
return { theme, isDark, setTheme, prefersDarkMode, checkTheme, setHighlightJs }
}
120 changes: 63 additions & 57 deletions src/design/themes/overrides/Input.ts
Original file line number Diff line number Diff line change
@@ -1,65 +1,71 @@
import { Theme } from "@mui/material";

export default function Input(theme: Theme) {
return {
MuiInputBase: {
styleOverrides: {
root: {
'&.Mui-disabled': {
'& svg': { color: theme.palette.text.disabled }
}
return {
MuiInputBase: {
styleOverrides: {
root: {
'&.Mui-disabled': {
'& svg': { color: theme.palette.text.disabled }
}
},
input: {
'&::placeholder': {
opacity: 1,
color: theme.palette.text.disabled
},
'&:-webkit-autofill, &:-internal-autofill-selected, &:-internal-autofill-previewed': {
boxShadow: 'unset !important',
WebkitTextFillColor: `${theme.palette.text.primary} !important`,
caretColor: `${theme.palette.text.primary} !important`,
transition: "background-color 5000000s ease-in-out 0s;"
}
}
}
},
input: {
'&::placeholder': {
opacity: 1,
color: theme.palette.text.disabled
}
}
}
},
MuiInput: {
styleOverrides: {
underline: {
'&:before': {
borderBottomColor: theme.palette.grey[500_56]
}
}
}
},
MuiFilledInput: {
styleOverrides: {
root: {
backgroundColor: theme.palette.grey[500_12],
'&:hover': {
backgroundColor: theme.palette.grey[500_16]
},
'&.Mui-focused': {
backgroundColor: theme.palette.action.focus
},
'&.Mui-disabled': {
backgroundColor: theme.palette.action.disabledBackground
}
MuiInput: {
styleOverrides: {
underline: {
'&:before': {
borderBottomColor: theme.palette.grey[500_56]
}
}
}
},
underline: {
'&:before': {
borderBottomColor: theme.palette.grey[500_56]
}
}
}
},
MuiOutlinedInput: {
styleOverrides: {
root: {
'& .MuiOutlinedInput-notchedOutline': {
borderColor: theme.palette.grey[500_32]
},
'&.Mui-disabled': {
'& .MuiOutlinedInput-notchedOutline': {
borderColor: theme.palette.action.disabledBackground
MuiFilledInput: {
styleOverrides: {
root: {
backgroundColor: theme.palette.grey[500_12],
'&:hover': {
backgroundColor: theme.palette.grey[500_16]
},
'&.Mui-focused': {
backgroundColor: theme.palette.action.focus
},
'&.Mui-disabled': {
backgroundColor: theme.palette.action.disabledBackground
}
},
underline: {
'&:before': {
borderBottomColor: theme.palette.grey[500_56]
}
}
}
},
MuiOutlinedInput: {
styleOverrides: {
root: {
'& .MuiOutlinedInput-notchedOutline': {
borderColor: theme.palette.grey[500_32]
},
'&.Mui-disabled': {
'& .MuiOutlinedInput-notchedOutline': {
borderColor: theme.palette.action.disabledBackground
}
}
}
}
}
}
}
}
};
};
}
14 changes: 4 additions & 10 deletions src/layout/default/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,6 @@ const InputSearch = styled(InputBase, { shouldForwardProp: prop => prop !== 'act
...active ? {
border: `1px solid ${theme.palette.customColor.linkIcon} !important`,
} : {},
'& input:-webkit-autofill, & input:-internal-autofill-selected, & input:-internal-autofill-previewed': {
WebkitBoxShadow: `0 0 0 100px ${theme.palette.customColor.search} inset`,
WebkitTextFillColor: `${theme.palette.text.primary}`,
caretColor: `${theme.palette.text.primary}`,
backgroundColor: `${theme.palette.customColor.search} !important`
},
}))
function Search() {
const router = useRouter();
Expand Down Expand Up @@ -227,9 +221,9 @@ function Search() {
return (
<>
<Hidden only={['md', 'xs']}>
<Form sx={{ flexGrow: { lg: 1, sm: 1, xl: 1, md: 0, xs: 0 } }} onSubmit={handleSearch}>
<Form sx={{ flexGrow: { lg: 1, sm: 1, xl: 1, md: 0, xs: 0 }, ml: '8px!important' }} onSubmit={handleSearch}>
<InputSearch
sx={{ px: 2, py: 1 }}
sx={{ px: 2, py: 0.5, borderRadius: 1.8 }}
id='search-input-home'
active={focus}
value={q}
Expand Down Expand Up @@ -308,8 +302,8 @@ export default function DefaultNavbar({ logo, tableContent }: NavbarProps) {
<Grid container spacing={2} sx={{ height: 80 }}>
<Grid item xs={6} lg={3}>
<Stack direction="row" alignItems="center" justifyContent='flex-start' spacing={1.5} height='100%'>
<Box sx={{ pr: 2, display: 'inline-flex' }}>
<Logo href="/?utm_source=portalnesia+web&utm_medium=header" svg={{ size: 35 }} {...logo} />
<Box sx={{ pr: 1, display: 'inline-flex' }}>
<Logo href="/?utm_source=portalnesia+web&utm_medium=header" svg={{ size: 40 }} {...logo} />
</Box>
<Hidden only={['md', 'xs']}>
<Search />
Expand Down
73 changes: 38 additions & 35 deletions src/pages/404.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import React from 'react'
import {useRouter} from 'next/router'
import { useRouter } from 'next/router'
import Head from 'next/head'
import { NextSeo,LogoJsonLd } from 'next-seo';
import { NextSeo, LogoJsonLd } from 'next-seo';
import { portalUrl, staticUrl } from '@utils/main';
import { Span } from '@design/components/Dom';
import Typography from '@mui/material/Typography';

const titleMeta="Page Not Found – Portalnesia";
const descMeta="The page you are looking for cannot be found anywhere.";
const imageMeta=staticUrl("og_image_default.png")
const titleMeta = "Page Not Found – Portalnesia";
const descMeta = "The page you are looking for cannot be found anywhere.";
const imageMeta = staticUrl("og_image_default.png")

const Custom404 = () => {
const router = useRouter();

const Custom404=()=>{
const router=useRouter();

return (
<div>
<NextSeo
Expand All @@ -20,27 +20,27 @@ const Custom404=()=>{
nofollow
noindex
additionalMetaTags={[{
property:'fb:pages',
content:'105006081218628'
},{
name:'viewport',
content:'width=device-width, initial-scale=1, shrink-to-fit=yes'
property: 'fb:pages',
content: '105006081218628'
}, {
name: 'viewport',
content: 'width=device-width, initial-scale=1, shrink-to-fit=yes'
}]}
openGraph={{
url: portalUrl(router.asPath),
title: titleMeta,
description: descMeta,
images: [
{ url: imageMeta },
],
site_name: "Portalnesia",
type:'website'
url: portalUrl(router.asPath),
title: titleMeta,
description: descMeta,
images: [
{ url: imageMeta },
],
site_name: "Portalnesia",
type: 'website'
}}
facebook={{appId:'313154633008072'}}
facebook={{ appId: '313154633008072' }}
twitter={{
handle: '@putuaditya_sid',
site: '@portalnesia1',
cardType: 'summary_large_image',
handle: '@putuaditya_sid',
site: '@portalnesia1',
cardType: 'summary_large_image',
}}
/>
<LogoJsonLd
Expand All @@ -50,20 +50,23 @@ const Custom404=()=>{
<Head>
<link rel="icon" href="/favicon.ico" />
</Head>
<div id="article">
<h1>Page not found!</h1>
<div>
<p>The page you are looking for cannot be found anywhere.</p><p>If you feel this is a mistake, please contact us at <a href="mailto:support@portalnesia.com"><Span sx={{color:'#dc8100'}}>support@portalnesia.com</Span></a>.</p>
<p>&mdash; Portalnesia</p>
<div id="article" style={{ display: "flex", justifyContent: "center", flexDirection: "column", minHeight: "100svh" }}>
<Typography variant="h1" sx={{ color: "white" }} paragraph>Page not found!</Typography>
<div style={{ marginTop: 16 }}>
<Typography variant="h4" component="p" sx={{ color: "white", fontWeight: "normal" }} gutterBottom>The page you are looking for cannot be found anywhere.</Typography><Typography variant="h4" component="p" sx={{ color: "white", fontWeight: "normal" }} gutterBottom>If you feel this is a mistake, please contact us at <a href="mailto:support@portalnesia.com"><span>support@portalnesia.com</span></a>.</Typography>
<Typography variant="h4" component="p" sx={{ color: "white" }} gutterBottom>&mdash; Portalnesia</Typography>
</div>
</div>
<style jsx global>{`
body { text-align: center; padding: 150px;background-color:#2f6f4e !important;font: 20px Helvetica, sans-serif; color: #FFF!important;}
h1 { font-size: 40px; }
p { font-size: 20px; }
body { text-align: center; background-color:#2f6f4e !important;font: 20px Helvetica, sans-serif; color: #FFF!important;margin:0;}
a {color: #dc8100;text-decoration: none;}
a:hover {color: #ff9600;}
#article { display: block; text-align: left; max-width: 650px; margin: 0 auto; }
@media(max-width:776px){
body{padding:150px 50px;}
body{padding:30px;}
}
@media(max-width:776px){
body{padding:10px;}
}
`}</style>
</div>
Expand Down
Loading

0 comments on commit 2235df2

Please sign in to comment.