-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
180 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
"use client"; | ||
import { | ||
Paper, | ||
Grid | ||
} from "@mui/material"; | ||
import { | ||
sidebarMode | ||
} from "../../layout/layoutClient"; | ||
import { | ||
ReactNode, | ||
useContext | ||
} from "react"; | ||
export default function Module(props: { | ||
children: ReactNode; | ||
mode: sidebarMode; | ||
}) { | ||
const mode = useContext(sidebarMode), | ||
isThis = props.mode === mode.value; | ||
return ( | ||
<Grid item> | ||
<Paper onClick={event => { | ||
mode.set(props.mode); | ||
}} sx={{ | ||
p: 3, | ||
display: "flex", | ||
flexDirection: "column", | ||
alignItems: "center", | ||
boxShadow: theme => isThis ? `inset 0 0 0 3px ${theme.palette.primary[theme.palette.mode]}` : "", | ||
borderColor: theme => isThis ? theme.palette.primary[theme.palette.mode] : "" | ||
}}> | ||
{props.children} | ||
</Paper> | ||
</Grid> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
"use client"; | ||
const defaults = { | ||
primary: '#2196f3', | ||
secondary: '#f50057', | ||
}; | ||
export default defaults; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
"use client"; | ||
const hues = [ | ||
'red', | ||
'pink', | ||
'purple', | ||
'deepPurple', | ||
'indigo', | ||
'blue', | ||
'lightBlue', | ||
'cyan', | ||
'teal', | ||
'green', | ||
'lightGreen', | ||
'lime', | ||
'yellow', | ||
'amber', | ||
'orange', | ||
'deepOrange' | ||
]; | ||
export default hues; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
"use client"; | ||
const shades = [ | ||
900, | ||
800, | ||
700, | ||
600, | ||
500, | ||
400, | ||
300, | ||
200, | ||
100, | ||
50, | ||
'A700', | ||
'A400', | ||
'A200', | ||
'A100', | ||
]; | ||
export default shades; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
"use client"; | ||
import { | ||
Paper, | ||
Typography | ||
} from "@mui/material"; | ||
import { | ||
useState | ||
} from "react"; | ||
import { | ||
get | ||
} from "react-intl-universal"; | ||
import { | ||
collocation | ||
} from "./page"; | ||
export default function SingleCollocation(props: { | ||
collocation: collocation; | ||
}) { | ||
const [elevation, setElevation] = useState<number>(2); | ||
return ( | ||
<Paper sx={{ | ||
p: 2 | ||
}} elevation={elevation} onMouseEnter={event => { | ||
setElevation(8); | ||
}} onMouseLeave={event => { | ||
setElevation(2); // reset to default | ||
}}> | ||
{props.collocation.map((value, index) => <Typography sx={{ | ||
mb: index === 1 ? 1 : "" | ||
}} key={index}>{get(`pillar.collocationShow.${index}`)}: {value}</Typography>)} | ||
</Paper> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,84 @@ | ||
"use client"; | ||
import { | ||
Box, | ||
FormControl, | ||
FormControlLabel, | ||
FormGroup, | ||
FormLabel, | ||
Radio, | ||
RadioGroup, | ||
TextField | ||
TextField, | ||
Typography | ||
} from "@mui/material"; | ||
import { | ||
useMemo, | ||
useState | ||
} from "react"; | ||
import { | ||
get | ||
} from "react-intl-universal"; | ||
import SingleCollocation from "./SingleCollocation"; | ||
type type = 0 | 1 | 2; | ||
/** | ||
* 0:间隔 | ||
* 1:柱子 | ||
*/ | ||
const examples: (0 | 1)[][] = [[0, 1, 0], [1, 0, 1, 0], [1, 0, 1]]; | ||
/** | ||
* 0:柱子长度 | ||
* 1:柱子个数 | ||
* 2:间隔长度 | ||
* 3:间隔个数 | ||
*/ | ||
export type collocation = [number, number, number, number]; | ||
export default function Pillar(): JSX.Element { | ||
const [type, setType] = useState<0 | 1 | 2>(2); | ||
const [type, setType] = useState<type>(2), | ||
[length, setLength] = useState<number>(0), | ||
pillars = useMemo<collocation[]>(() => [[1, 1, 1, 1]], [type, length]); | ||
return ( | ||
<> | ||
<FormGroup> | ||
<FormControl sx={{ | ||
mb: "9px" | ||
}}> | ||
<TextField label={get("pillar.length")} variant="outlined" type="number" /> | ||
<TextField | ||
value={length} | ||
onChange={event => setLength(Number(event.target.value))} | ||
label={get("pillar.length")} | ||
variant="outlined" | ||
type="number" | ||
/> | ||
</FormControl> | ||
<FormControl> | ||
<FormLabel id="chooses-label">{get("pillar.position")}</FormLabel> | ||
<RadioGroup aria-labelledby="chooses-label" defaultValue={0} name="chooses-group"> | ||
{[0, 1, 2].map((single) => <FormControlLabel value={single} key={single} control={<Radio />} label={get(`pillar.types.${single}`)} />)} | ||
<RadioGroup aria-labelledby="chooses-label" value={type} onChange={(event, value) => setType(Number(value) as type)} name="chooses-group"> | ||
{[0, 1, 2].map((single) => ( | ||
<Box key={single} sx={{ | ||
display: "flex" | ||
}}> | ||
<FormControlLabel value={single} control={<Radio />} label={get(`pillar.types.${single}`)} /> | ||
{examples[single].map((block, index) => { | ||
const pillar = block === 1; | ||
return ( | ||
<Box key={index} sx={{ | ||
mb: 1, | ||
width: 48, | ||
height: 48, | ||
display: "inline-flex", | ||
alignItems: "center", | ||
justifyContent: "center", | ||
boxShadow: theme => `inset 0 0 0 3px ${theme.palette[pillar ? "primary" : "secondary"][theme.palette.mode]}`, | ||
}}> | ||
<Typography>{pillar ? get("pillar.name") : get("pillar.distance")}</Typography> | ||
</Box> | ||
); | ||
})} | ||
</Box> | ||
))} | ||
</RadioGroup> | ||
</FormControl> | ||
</FormGroup> | ||
{pillars.map(single => <SingleCollocation key={single.toString()} collocation={single} />)} | ||
</> | ||
); | ||
}; |