blob: fbaff5ae1490219aa9ce5727690dc72e4737aa27 [file] [log] [blame]
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import Paper from "@mui/material/Paper";
import { styled } from "@mui/material/styles";
import Switch from "@mui/material/Switch";
export const Item = styled(Paper)(({ theme }) => ({
backgroundColor:
theme.palette.mode === "dark" ? "#1A2027" : "rgba(255,255,255,0.6)",
...theme.typography.body2,
padding: 0,
textAlign: "center",
color: theme.palette.text.secondary,
flexGrow: 1
}));
export const StyledPaper = styled(Paper)(({ theme }) => ({
backgroundColor:
theme.palette.mode === "dark" ? "#1A2027" : "rgba(255,255,255,0.6)",
...theme.typography.body2,
padding: theme.spacing(2),
color: theme.palette.text.primary
}));
export const samePageLinkNavigation = (
event: React.MouseEvent<HTMLAnchorElement, MouseEvent>
) => {
if (
event.defaultPrevented ||
event.button !== 0 ||
event.metaKey ||
event.ctrlKey ||
event.altKey ||
event.shiftKey
) {
return false;
}
return true;
};
export const AntSwitch = styled(Switch)(({ theme }) => ({
width: 28,
height: 16,
padding: 0,
display: "flex",
"&:active": {
"& .MuiSwitch-thumb": {
width: 15
},
"& .MuiSwitch-switchBase.Mui-checked": {
transform: "translateX(9px)"
}
},
"& .MuiSwitch-switchBase": {
padding: 2,
"&.Mui-checked": {
transform: "translateX(12px)",
color: "#fff",
"& + .MuiSwitch-track": {
opacity: 1,
backgroundColor: theme.palette.mode === "dark" ? "#177ddc" : "#1890ff"
}
}
},
"& .MuiSwitch-thumb": {
boxShadow: "0 2px 4px 0 rgb(0 35 11 / 20%)",
width: 12,
height: 12,
borderRadius: 6,
transition: theme.transitions.create(["width"], {
duration: 200
})
},
"& .MuiSwitch-track": {
borderRadius: 16 / 2,
opacity: 1,
backgroundColor:
theme.palette.mode === "dark"
? "rgba(255,255,255,.35)"
: "rgba(0,0,0,.25)",
boxSizing: "border-box"
}
}));