Skip to content

Commit

Permalink
max char per line 100
Browse files Browse the repository at this point in the history
  • Loading branch information
ZibanPirate committed Jul 9, 2024
1 parent 89c9d1d commit f00a3d9
Show file tree
Hide file tree
Showing 12 changed files with 303 additions and 337 deletions.
4 changes: 4 additions & 0 deletions webv2/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
root = true

[*]
max_line_length = 100
4 changes: 1 addition & 3 deletions webv2/rsbuild.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ let bundleInfo: { version: string } = {
version: `v${require('./package.json').version as string}`, // eslint-disable-line @typescript-eslint/no-var-requires
};
try {
bundleInfo = JSON.parse(
readFileSync('.bundle-info.json').toString(),
) as typeof bundleInfo;
bundleInfo = JSON.parse(readFileSync('.bundle-info.json').toString()) as typeof bundleInfo;
} catch (error) {
console.log(`no .bundle-info.json found`);
}
Expand Down
13 changes: 2 additions & 11 deletions webv2/src/components/footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,14 @@ export function Footer({ sections }: FooterProps): JSX.Element {
<Locale localeKey={localeKey} />
</h6>
{links.map(({ localeKey, href }, linkIndex) => (
<Link
key={`link-${linkIndex}`}
className="link-hover link"
href={href}
>
<Link key={`link-${linkIndex}`} className="link-hover link" href={href}>
<Locale localeKey={localeKey} />
</Link>
))}
</nav>
))}
<aside>
<Image
src={logoSquare}
alt="DzCode i/o SVG log square"
width={80}
height={80}
/>
<Image src={logoSquare} alt="DzCode i/o SVG log square" width={80} height={80} />
<p className="pl-2">
<Locale global-algeria-codes />
</p>
Expand Down
5 changes: 1 addition & 4 deletions webv2/src/components/link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ interface LinkProps extends Omit<RRLinkProps, 'to'> {

const initialLanguageCode = getInitialLanguageCode();

export function Link({
href,
...props
}: PropsWithChildren<LinkProps>): JSX.Element {
export function Link({ href, ...props }: PropsWithChildren<LinkProps>): JSX.Element {
if (initialLanguageCode !== Languages[0].code) {
href = `/${initialLanguageCode}${href}`;
}
Expand Down
2 changes: 1 addition & 1 deletion webv2/src/components/loadable/loadable-factory.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import loadable from "@loadable/component";
import loadable from '@loadable/component';

export const loadableFactory = loadable;
557 changes: 280 additions & 277 deletions webv2/src/components/locale/dictionary.ts

Large diffs are not rendered by default.

5 changes: 1 addition & 4 deletions webv2/src/components/locale/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,4 @@ import { factory } from './factory';
import { dictionary } from './dictionary';
import { getAppState } from 'src/redux/store';

export const Locale = factory(
dictionary,
() => getAppState().settings.languageCode,
);
export const Locale = factory(dictionary, () => getAppState().settings.languageCode);
24 changes: 5 additions & 19 deletions webv2/src/components/top-bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ export function TopBar({ version, links }: TopBarProps): JSX.Element {
return links.findIndex(({ href }) => pathname === href);
}, [pathname, links]);

const selectedLanguageCode = useAppSelector(
(state) => state.settings.languageCode,
);
const selectedLanguageCode = useAppSelector((state) => state.settings.languageCode);

const { selectedLanguage, languageOptions } = useMemo(() => {
let selectedLanguage!: Language;
Expand All @@ -45,20 +43,15 @@ export function TopBar({ version, links }: TopBarProps): JSX.Element {
alt="DzCode i/o SVG Logo wide"
/>
</Link>
<Link
href={`https://github.com/dzcode-io/dzcode.io/releases/tag/${version}`}
>
<Link href={`https://github.com/dzcode-io/dzcode.io/releases/tag/${version}`}>
{version}
</Link>
<div className="flex-1" />
<div className="dropdown dropdown-end">
<div tabIndex={0} role="button">
{selectedLanguage.label}
</div>
<ul
tabIndex={0}
className="menu dropdown-content z-[1] rounded-box bg-base-300"
>
<ul tabIndex={0} className="menu dropdown-content z-[1] rounded-box bg-base-300">
{languageOptions.map(({ code, label }, index) => (
<li
key={index}
Expand Down Expand Up @@ -88,11 +81,7 @@ export function TopBar({ version, links }: TopBarProps): JSX.Element {
>
<path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"></path>
</svg>
<input
type="checkbox"
value="dzcode_light"
className="theme-controller toggle"
/>
<input type="checkbox" value="dzcode_light" className="theme-controller toggle" />
<svg
xmlns="http://www.w3.org/2000/svg"
width="20"
Expand All @@ -118,10 +107,7 @@ export function TopBar({ version, links }: TopBarProps): JSX.Element {
alt="DzCode i/o SVG Logo wide"
/>
</Link>
<div
role="tablist"
className="tabs tabs-lifted tab-border-none tabs-lg overflow-x-auto"
>
<div role="tablist" className="tabs tabs-lifted tab-border-none tabs-lg overflow-x-auto">
{links.map(({ localeKey, href }, index) => (
<Link
href={href}
Expand Down
8 changes: 2 additions & 6 deletions webv2/src/redux/actions/settings.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { Language, Languages } from 'src/components/locale/languages';

export const changeLanguage = async (
languageCode: Language['code'],
): Promise<void> => {
export const changeLanguage = async (languageCode: Language['code']): Promise<void> => {
// case 1: url has no language code, eg: /about / or root
// case 2: url has language code, eg: /en/about /ar/ or /ar
// case 3: url has language code, but not in the list of supported languages, eg: /es/about /es/ or /es
Expand All @@ -15,9 +13,7 @@ export const changeLanguage = async (
return;
}

const urlLanguageRegEx = new RegExp(
`^/(${Languages.map(({ code }) => code).join('|')})`,
);
const urlLanguageRegEx = new RegExp(`^/(${Languages.map(({ code }) => code).join('|')})`);

const urlLanguageMatch = newPath.match(urlLanguageRegEx);
if (urlLanguageMatch) {
Expand Down
4 changes: 2 additions & 2 deletions webv2/src/redux/hooks.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useDispatch, useSelector, useStore } from "react-redux";
import type { AppDispatch, AppStore, AppState } from "./store";
import { useDispatch, useSelector, useStore } from 'react-redux';
import type { AppDispatch, AppStore, AppState } from './store';

export const useAppDispatch = useDispatch.withTypes<AppDispatch>();
export const useAppSelector = useSelector.withTypes<AppState>();
Expand Down
4 changes: 1 addition & 3 deletions webv2/src/redux/slices/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ let initialLanguageCode: Language['code'] | null = null;
export function getInitialLanguageCode(): Language['code'] {
if (!initialLanguageCode) {
const language =
Languages.find(({ code }) =>
window.location.pathname.startsWith(`/${code}`),
) || Languages[0];
Languages.find(({ code }) => window.location.pathname.startsWith(`/${code}`)) || Languages[0];
initialLanguageCode = language.code;
}
if (initialLanguageCode === 'ar') {
Expand Down
10 changes: 3 additions & 7 deletions webv2/src/utils/typescript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@ export type PyramidSplitString<
S extends string,
D extends string,
// @ts-expect-error: @TODO: look into why this happens
> = S extends `${infer L}-${PopSubString<S, D>}`
? [L, ...PyramidSplitString<L, D>]
: [];
> = S extends `${infer L}-${PopSubString<S, D>}` ? [L, ...PyramidSplitString<L, D>] : [];

export type PartialWithOneRequiredKey<
T,
U = { [K in keyof T]: Pick<T, K> },
> = Partial<T> & U[keyof U];
export type PartialWithOneRequiredKey<T, U = { [K in keyof T]: Pick<T, K> }> = Partial<T> &
U[keyof U];

0 comments on commit f00a3d9

Please sign in to comment.