Skip to content

Commit

Permalink
Merge branch 'main' into prod
Browse files Browse the repository at this point in the history
  • Loading branch information
XueMoMo committed Sep 15, 2023
2 parents 14e1c6e + 8555e68 commit 6f5a979
Show file tree
Hide file tree
Showing 39 changed files with 2,426 additions and 2,174 deletions.
3 changes: 2 additions & 1 deletion components/common/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import { FaSpinner } from "react-icons/fa";

export function Button(p: HTMLAttributes<HTMLButtonElement>) {
const { children, className, ...other } = p;

return (
<button {...other} className={classNames(className, "hover:bg-green-28")}>
<button {...other} className={classNames(className)}>
{p.children}
</button>
);
Expand Down
2 changes: 1 addition & 1 deletion components/common/carbonLayout/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export function CarbonHeader(p: HTMLAttributes<HTMLDivElement>) {
<>
<div
className={classNames(
"w-full relative z-[3] max-w-[90rem] mx-auto text-white flex items-center top-0 px-[7.5rem] h-[4.25rem]",
"w-full relative z-[3] max-w-[90rem] mx-auto text-white flex items-center top-0 h-[4.25rem]",
className,
)}
{...other}>
Expand Down
42 changes: 29 additions & 13 deletions components/common/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { useT } from "@lib/hooks/useT";
import { handleCarbonStr, sleep, textTo2 } from "@lib/utils";
import { FiHome, FiLogIn, FiLogOut, FiSearch } from "react-icons/fi";
import { VscAccount } from "react-icons/vsc";
import Document from "@public/document.svg";

export function useMenus(data: any[] = []) {
const isMobile = useIsMobile();
Expand Down Expand Up @@ -46,16 +47,14 @@ export function useMenus(data: any[] = []) {
}))
.forEach((item) => menus.push(item));
}
// menus.push({
// topSplit: true,
// icon: <IoLanguageOutline />,
// text: LngsText[lng],
// onClick: () => {
// // alert(11)
// // alert(SupportLngs.find((item) => item !== lng))
// i18n.changeLanguage(SupportLngs.find((item) => item !== lng));
// },
// });
menus.push({
icon: <Document />,
text: t("Document"),
to: "https://docs.gtech.world/",
onClick: () => {
push("https://docs.gtech.world/");
},
});
menus.push({
icon: user ? <FiLogOut /> : <FiLogIn />,
text: user ? t("Log Out") : t("Log In"),
Expand Down Expand Up @@ -109,9 +108,10 @@ export function Header(
showQuery?: boolean;
isManager?: boolean;
menus?: any;
nopx?: boolean;
},
) {
const { children, className, tits, showQuery, isManager, menus, ...other } = p;
const { children, className, tits, showQuery, isManager, nopx = false, menus, ...other } = p;
const { t } = useT();
const mTit = tits || t("Automotive Industry Carbon Platform") || "";
const mTits = useMemo(() => textTo2(mTit), [mTit]);
Expand All @@ -124,16 +124,32 @@ export function Header(
setLastInputVin(e.target.value);
}, []);
const onError = useOnError();

const [windowWidth, setWindowWidth] = useState(0);

useEffect(() => {
const handleResize = () => {
setWindowWidth(window.innerWidth);
};
setWindowWidth(window.innerWidth);
window.addEventListener("resize", handleResize);
return () => {
window.removeEventListener("resize", handleResize);
};
}, []);
const onQuery = () => {
if (!vin) return onError("Please input VIN Code");
push(`pcf?vin=${vin}`);
};

return (
<>
<div
id="app_header"
className={classNames(
"w-full relative z-[3] max-w-[90rem] mx-auto text-white flex items-center top-0 px-[7.5rem] h-[4.25rem]",
`w-full relative z-[3] max-w-[90rem] mx-auto text-white flex items-center top-0 h-[4.25rem]
${!nopx && (windowWidth > 1200 && windowWidth <= 1280 ? "px-[3%]" : "px-[7.5rem]")}
`,
className,
)}
{...other}>
Expand All @@ -158,7 +174,7 @@ export function Header(

<div className="flex-1" />
{showQuery && (
<div className="relative text-white text-lg mr-4 mo:hidden">
<div className="relative mr-4 text-lg text-white mo:hidden">
<input
style={{ border: "2px solid #fff" }}
className="w-[17.5rem] h-[2.25rem] rounded-sm outline-none bg-transparent pl-10 pr-4"
Expand Down
16 changes: 9 additions & 7 deletions components/common/headerLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ export function HomeHeaderLayout(p: HTMLAttributes<HTMLDivElement>) {
const { className, children, ...props } = p;
const isMobile = useIsMobile();
return (
<div className="flex-1 flex flex-col min-h-fit w-full bg-gray-16 relative">
<div className="relative flex flex-col flex-1 w-full min-h-fit bg-gray-16 ">
{isMobile ? (
<div className="absolute z-0 top-0 w-full h-[43rem] overflow-hidden bg-green-2 ">
<img className="object-cover w-full absolute right-0 bottom-0" src="/home-bg-r.jpg" />
<img className="absolute bottom-0 right-0 object-cover w-full" src="/home-bg-r.jpg" />
<div
className="w-full h-full absolute ssm:top-[calc(21.5rem_-_75vw)]"
style={{
Expand All @@ -20,8 +20,8 @@ export function HomeHeaderLayout(p: HTMLAttributes<HTMLDivElement>) {
/>
</div>
) : (
<div className="absolute z-0 top-0 w-full h-[48.75rem] bg-green-2 overflow-hidden">
<img className="object-cover h-full absolute right-0 top-0" src="/home-bg-r.jpg" />
<div className="absolute z-0 top-0 w-full h-[48.75rem] bg-green-2 overflow-hidden ">
<img className="absolute top-0 right-0 object-cover h-full" src="/home-bg-r.jpg" />
<div
className="w-full h-full absolute lg:left-[calc(50%_-_45rem)]"
style={{
Expand Down Expand Up @@ -52,17 +52,19 @@ export function HeaderLayout(
p: HTMLAttributes<HTMLDivElement> & {
tits?: string | null;
isManager?: boolean;
nopx?: boolean;
},
) {
const { className, tits, isManager, children, ...props } = p;
const { className, tits, isManager, nopx, children, ...props } = p;
const isMobile = useIsMobile();
const h = useHeaderTipHeight();
return (
<div className="flex-1 flex flex-col min-h-fit w-full relative">
<div className="relative flex flex-col flex-1 w-full min-h-fit">
{isMobile ? (
<MobileHeader />
) : (
<Header
nopx={nopx}
tits={tits}
isManager={isManager}
style={{ top: `${h}px` }}
Expand All @@ -82,7 +84,7 @@ export function MainHeaderLayout(p: { showQuery?: boolean; menus?: any[] } & HTM
const { className, children, showQuery = true, menus = [], ...props } = p;
const h = useHeaderTipHeight();
return (
<div className="flex-1 w-full flex flex-col min-h-fit bg-gray-16 relative">
<div className="relative flex flex-col flex-1 w-full min-h-fit bg-gray-16">
<Header
menus={menus}
isManager={true}
Expand Down
88 changes: 88 additions & 0 deletions components/common/mermaid.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import classNames from "classnames";
import mermaid, { MermaidConfig } from "mermaid";
import { useMemo } from "react";
import { useDebounce, useMeasure } from "react-use";
import panzoom from "svg-pan-zoom";

const DEFAULT_CONFIG: MermaidConfig = {
startOnLoad: true,
theme: "default",
logLevel: "fatal",
securityLevel: "strict",
arrowMarkerAbsolute: false,
flowchart: {
htmlLabels: true,
},

themeVariables: {
// primaryColor: "#00ff00",
// primaryTextColor: "#000",
// primaryBorderColor: "#7C0000",
// lineColor: "black",
// secondaryColor: "#006100",
// tertiaryColor: "#fff",
},
sequence: {
diagramMarginX: 50,
diagramMarginY: 10,
actorMargin: 50,
width: 800,
height: 200,
boxMargin: 10,
boxTextMargin: 5,
noteMargin: 10,
messageMargin: 35,
mirrorActors: true,
bottomMarginAdj: 1,
useMaxWidth: true,
rightAngles: false,
showSequenceNumbers: false,
wrapPadding: 20,
},
gantt: {
titleTopMargin: 25,
barHeight: 16,
barGap: 4,
topPadding: 50,
leftPadding: 75,
gridLineStartPadding: 35,
fontSize: 11,
numberSectionStyles: 4,
axisFormat: "%Y-%m-%d",
},
class: {
titleTopMargin: 20,
defaultRenderer: "dagre-wrapper",
},
pie: {},
};

const refCount = {
count: 1,
};
export function Mermaid(p: { className?: string; data?: string }) {
const { className, data = "" } = p;
const id = useMemo(() => `aicp_mermaid_${refCount.count++}`, []);
const renderData = async () => {
try {
const el = document.querySelector("#" + id);
if (!el) return;
mermaid.initialize(DEFAULT_CONFIG);
const { svg, bindFunctions } = await mermaid.render(id + "-svg", data);
el.innerHTML = svg;
bindFunctions?.(el);
const svgel = document.getElementById(id + "-svg");
if (!svgel) return;
svgel.setAttribute("height", "100%");
svgel.style.maxWidth = "100%";
panzoom(svgel, { mouseWheelZoomEnabled: false, zoomEnabled: true, controlIconsEnabled: true });
} catch (error) {
console.error(error);
}
};
const [ref, { width }] = useMeasure<HTMLDivElement>();
useDebounce(renderData, 300, [width, data]);
return <div ref={ref} id={id} className={classNames("mermaid p-2.5", className)} />;
}

export default Mermaid;
3 changes: 3 additions & 0 deletions components/common/pagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,15 @@ export function Pagination(p: Props & HTMLAttributes<HTMLDivElement>) {
onChange && pgNum < count && onChange(pgNum + 1, count);
};
const doFirst = () => {
if (pgNum === 1) return;
onChange && onChange(1, count);
};
const doPrev = () => {
onChange && pgNum > 1 && onChange(pgNum - 1, count);
};
const doLast = () => {
if (count === pgNum) return;

onChange && onChange(count);
};
if (total <= pgSize) return null;
Expand Down
4 changes: 2 additions & 2 deletions components/common/simpleTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export interface TableProps {

export function DefEmpty() {
return (
<tr className=" text-black text-center text-lg font-normal ">
<tr className="text-lg font-normal text-center text-black ">
<td colSpan={100} className="h-[100px] py-5 align-top">
无数据
</td>
Expand All @@ -26,7 +26,7 @@ export const STable = ({
header,
data,
empty = <DefEmpty />,
className = "min-w-full relative",
className = "relative min-w-full bg-neutral-200 ",
headerClassName = "bg-neutral-200 sticky top-0 text-left text-black text-lg font-bold leading-[27px]",
headerItemClassName = "p-3",
tbodyClassName = "bg-white ",
Expand Down
Loading

0 comments on commit 6f5a979

Please sign in to comment.