Skip to content

Commit

Permalink
Merge pull request #176 from forbole/refactor-product-panel
Browse files Browse the repository at this point in the history
chore: refactors and optimized build
  • Loading branch information
icfor authored Jan 8, 2024
2 parents afa4ec3 + 78eac73 commit dc30c85
Show file tree
Hide file tree
Showing 72 changed files with 481 additions and 547 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ RUN chown nextjs .

COPY --from=prod_node_modules --chown=nextjs:nodejs /app/node_modules ./node_modules
COPY --from=builder --chown=nextjs:nodejs /app/.next ./.next
COPY --from=builder --chown=nextjs:nodejs /app/scripts ./scripts
COPY --from=builder --chown=nextjs:nodejs /app/.yarn ./.yarn
COPY --from=builder --chown=nextjs:nodejs /app/.env ./.env
COPY --from=builder --chown=nextjs:nodejs /app/i18n.js ./i18n.js
Expand Down
8 changes: 7 additions & 1 deletion next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ const million = require("million/compiler");
const bundleAnalyzer = require("@next/bundle-analyzer");
const nextTranslate = require("next-translate-plugin");

const { changeCssClasses } = require("./scripts/change_css_classes");

const localePrefixes = ["", "/zh-HK", "/zh-CN"];

const withBundleAnalyzer = bundleAnalyzer({
Expand Down Expand Up @@ -45,12 +47,16 @@ const baseConfig = nextTranslate({
typescript: {
ignoreBuildErrors: process.env.QUICK_BUILD === "true",
},
webpack: (config) => {
webpack: (config, { dev }) => {
config.module.rules.push({
test: /\.svg$/,
use: ["@svgr/webpack"],
});

if (!dev) {
changeCssClasses(config);
}

return config;
},
});
Expand Down
38 changes: 38 additions & 0 deletions scripts/change_css_classes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
const path = require("path");
const loaderUtils = require("loader-utils");

const hashOnlyIdent = (context, _, exportName) =>
loaderUtils
.getHashDigest(
Buffer.from(
`filePath:${path
.relative(context.rootContext, context.resourcePath)
.replace(/\\+/g, "/")}#className:${exportName}`,
),
"md4",
"base64",
6,
)
.replace(/[^a-zA-Z0-9-_]/g, "_")
.replace(/^(-?\d|--)/, "_$1");

// https://stackoverflow.com/a/69166434
const changeCssClasses = (config) => {
config.module.rules.forEach((rule) => {
if (!rule.oneOf) return;

rule.oneOf.forEach((subRule) => {
if (!Array.isArray(subRule.use)) return;

subRule.use.forEach((use) => {
if (!use.loader?.includes("/css-loader")) return;

use.options.modules.getLocalIdent = hashOnlyIdent;
});
});
});
};

module.exports = {
changeCssClasses,
};
2 changes: 1 addition & 1 deletion src/components/arrow/index.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

svg {
path {
stroke: $color-forbole-blue;
stroke: $color-forbole-blue-1;
}

fill: #fff;
Expand Down
6 changes: 3 additions & 3 deletions src/components/carousel/index.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ $avater-shadow:
}

.description {
color: #2a1a6a;
color: $color-indigo-1;
font-size: 14px;
font-style: normal;
font-weight: 400;
Expand All @@ -53,7 +53,7 @@ $avater-shadow:
}

.name {
color: #202a43;
color: $color-forbole-blue-1;
font-size: 24px;
font-style: normal;
font-weight: 700;
Expand All @@ -80,7 +80,7 @@ $avater-shadow:
}

.position {
color: #202a43;
color: $color-forbole-blue-1;
font-size: 18px;
font-style: normal;
font-weight: 400;
Expand Down
2 changes: 1 addition & 1 deletion src/components/contact-form/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import useTranslation from "next-translate/useTranslation";
import { forwardRef } from "react";

import CtaButton from "../cta-button";
import FormInput from "../formInput";
import FormInput from "../form_input";

type Props = {
canSubmit: boolean;
Expand Down
6 changes: 2 additions & 4 deletions src/components/cta-button/index.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,8 @@
&:disabled {
&,
&:hover {
background: #ebeef5;
box-shadow:
0 10px 32px -4px rgba(125, 92, 255, 0.1),
0 6px 14px -6px rgba(126, 94, 255, 0.28);
background: $color-forbole-blue-5;
box-shadow: none;
color: rgba(195, 204, 226, 1);
cursor: not-allowed;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
margin-top: 4px;

&.staking {
border-color: $color-indigo;
border-color: $color-indigo-2;
}

@include down-laptop {
Expand All @@ -28,7 +28,7 @@
flex-direction: column;

@include down-laptop {
border-top: 1px solid $color-grey2;
border-top: 1px solid $color-light-grey-2;
gap: 8px;
padding-top: 12px;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

.inpboxItem {
align-items: center;
background-color: #34383e;
background-color: $color-dark-grey;
border-radius: 45px;
color: #fff;
display: flex;
Expand Down
4 changes: 2 additions & 2 deletions src/components/footer/components/social_media/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ import { socialMedia } from "@src/utils/social_media_info";
import * as styles from "./index.module.scss";

const SocialMedia = () => {
const socialKeys = ["github", "twitter", "telegram", "linkedIn", "Instagram"];
const socialKeys = ["github", "twitter", "telegram", "linkedin", "instagram"];
const { locale } = useRouter();

const socialMediaInfo = socialKeys.map((keyParam: string) => {
let key = keyParam;

if (key === "Instagram") {
if (key === "instagram") {
if (locale !== "en") {
key += "_zh";
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/footer/index.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
.wrapper {
background-repeat: no-repeat;
background-size: cover;
color: $color-indigo;
color: $color-indigo-2;
position: relative;
user-select: none;
z-index: 1;
Expand Down
47 changes: 0 additions & 47 deletions src/components/formInput/index.tsx

This file was deleted.

28 changes: 28 additions & 0 deletions src/components/form_input/index.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
@import "src/styles/sass.scss";

.input {
background-color: $color-white;
border: 2px solid;
border-color: #fff;
border-radius: 8px;
box-shadow: 4px 8px 24px 0 rgba(116, 81, 255, 0.28);
display: block;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
"Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji",
"Segoe UI Symbol";
font-size: 16px;
margin-top: spacing(2);
outline: none;
padding: 12px 16px;
position: relative;
transition: all 0.3s ease-in-out;
width: calc(100% - 36px);

&:focus {
border-color: $color-indigo-2;
}

&::placeholder {
color: $color-grey-2;
}
}
9 changes: 9 additions & 0 deletions src/components/form_input/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import * as styles from "./index.module.scss";

type Props = React.InputHTMLAttributes<HTMLInputElement>;

const FormInput = ({ className, ...props }: Props) => (
<input {...props} className={[styles.input, className].join(" ")} />
);

export default FormInput;
83 changes: 73 additions & 10 deletions src/components/four-table/index.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,9 @@
height: 536px;
}

.money {
font-size: 64px;
}

.popular {
align-items: center;
background: linear-gradient(315deg, #ee3131 0%, #ff426b 100%);
background: $gradient-unnamed-2;
border-radius: 32px;
box-sizing: border-box;
color: #fff;
Expand All @@ -53,10 +49,6 @@
line-height: normal;
}

.none {
display: none;
}

@media (max-width: 1024.95px) {
.active {
flex-basis: max-content;
Expand Down Expand Up @@ -91,7 +83,7 @@

.text {
align-items: baseline;
color: #202a43;
color: $color-forbole-blue-1;
display: flex;
font-size: 12px;
font-weight: 590;
Expand All @@ -101,6 +93,8 @@

.feature {
display: flex;
font-weight: 600;
gap: 5px;
margin-top: 20px;
}

Expand All @@ -112,3 +106,72 @@
margin-top: 16px;
}
}

.wrapper {
align-items: flex-end;
display: flex;
flex-direction: row;
gap: 16px;
min-height: 536px;

@include down-laptop {
align-items: center;
flex-direction: column;
gap: 24px;
justify-content: center;
}
}

.group {
display: flex;
flex-direction: row;

&.none {
display: none;
}
}

.title {
color: $color-forbole-blue-1;
font-size: 20px;
font-weight: 590;
}

.description {
color: $color-forbole-blue-1;
font-size: 16px;
font-weight: 400;
}

.features,
.item {
font-size: 16px;
font-weight: 590;
padding-left: 5px;
}

.dollar {
font-size: 16px;
font-weight: 590;
padding-right: 3px;
}

.price {
color: $color-forbole-blue-1;
font-size: 32px;
font-weight: 590;
letter-spacing: -0.508px;
margin-top: -23px;
padding-right: 7px;

&.money {
font-size: 64px;
}
}

.divider {
background-color: rgba(0, 0, 0, 0.12);
border-bottom-width: thin;
height: 1px;
margin-top: 24px;
}
Loading

0 comments on commit dc30c85

Please sign in to comment.