Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
NgocNhi123 committed Jun 24, 2024
1 parent 80f49bf commit 588f56a
Show file tree
Hide file tree
Showing 54 changed files with 245 additions and 209 deletions.
12 changes: 6 additions & 6 deletions .github/DEVELOP.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ To understand the principles that drive the design and development of Moai, see

Moai is a [monorepo](https://classic.yarnpkg.com/en/docs/workspaces/) powered by Yarn. There are several projects:

| Path | Project | Framework |
| ------- | ----------------- | ----------- |
| core | [@moai/core] | [Rollup] |
| gallery | [@moai/gallery] | [Rollup] |
| docs | [moai.thien.do] | [Storybook] |
| test | Test suits | [Jest] |
| Path | Project | Framework |
| ------- | --------------- | ----------- |
| core | [@moai/core] | [Rollup] |
| gallery | [@moai/gallery] | [Rollup] |
| docs | [moai.thien.do] | [Storybook] |
| test | Test suits | [Jest] |

The "test" and "docs" projects depend on "core" and "gallery" via symlinks. This means to run tests or start the docs site locally, you will need to build "core" and "gallery" first. Also, the "gallery" depends on the "core" project:

Expand Down
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
**Heads up!** This project is no longer in active development. It will be [archived](https://docs.github.com/en/repositories/archiving-a-github-repository/archiving-repositories) soon. Some suggestions:

- Build your own UI kit with a good foundation like [Radix](https://www.radix-ui.com/) or [Headless UI](https://headlessui.com/). This is what I'm actually doing these days myself.
- Fork this project. You have my sword, and bow, and axe, and only 22 unresolved bugs.
- Refactor Moai to utilise Radix (which is what I wanted to do, if I don't need to pay the bills)

- Build your own UI kit with a good foundation like [Radix](https://www.radix-ui.com/) or [Headless UI](https://headlessui.com/). This is what I'm actually doing these days myself.
- Fork this project. You have my sword, and bow, and axe, and only 22 unresolved bugs.
- Refactor Moai to utilise Radix (which is what I wanted to do, if I don't need to pay the bills)

<hr />

Expand Down
2 changes: 1 addition & 1 deletion core/src/button/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ const validateButton = (props: ButtonProps): void => {
// since it's missing the ref. See Button for the exported component.
const buttonRender = (
props: ButtonProps,
ref: React.ForwardedRef<ButtonElement>
ref: React.ForwardedRef<ButtonElement>,
): JSX.Element => {
validateButton(props);
const common = {
Expand Down
4 changes: 3 additions & 1 deletion core/src/button/color/failure.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
:global(.dark) .outset {
color: var(--white);
background-color: var(--failure-5);
box-shadow: var(--shadow), var(--inset-shadow) var(--failure-4);
box-shadow:
var(--shadow),
var(--inset-shadow) var(--failure-4);
font-weight: 500;
}

Expand Down
4 changes: 3 additions & 1 deletion core/src/button/color/highlight.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@
:global(.dark) .outset {
color: var(--white);
background-color: var(--highlight-5);
box-shadow: var(--shadow), var(--inset-shadow) var(--highlight-4);
box-shadow:
var(--shadow),
var(--inset-shadow) var(--highlight-4);
font-weight: 500;
}

Expand Down
8 changes: 6 additions & 2 deletions core/src/button/color/none.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
:global(.light) .outset {
--shadow: var(--shadow-size) rgba(0, 0, 0, 0.1);
background-color: var(--gray-0);
box-shadow: var(--shadow), var(--inset-shadow) var(--white);
box-shadow:
var(--shadow),
var(--inset-shadow) var(--white);
border-color: var(--gray-2);
}
:global(.light) .outset:hover {
Expand All @@ -39,7 +41,9 @@
:global(.dark) .outset {
--shadow: var(--shadow-size) rgba(0, 0, 0, 0.5);
background-color: var(--gray-6);
box-shadow: var(--shadow), var(--inset-shadow) var(--gray-5);
box-shadow:
var(--shadow),
var(--inset-shadow) var(--gray-5);
border-color: var(--black);
}
:global(.dark) .outset:hover {
Expand Down
4 changes: 3 additions & 1 deletion core/src/button/style/flat.module.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
.main {
transition: background-color 0.1s, outline 0.2s ease-out;
transition:
background-color 0.1s,
outline 0.2s ease-out;
border-radius: 0;
/* To have same layout with outset buttons */
border: solid 1px transparent;
Expand Down
5 changes: 4 additions & 1 deletion core/src/button/style/outset.module.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
.main {
transition: background-color 0.1s, box-shadow 0.1s, outline 0.2s ease-out;
transition:
background-color 0.1s,
box-shadow 0.1s,
outline 0.2s ease-out;
border: solid 1px transparent;
--shadow-size: 0px 0.5px 2px;
--inset-shadow: inset 0px 1px 0px;
Expand Down
2 changes: 1 addition & 1 deletion core/src/checkbox/checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export const Checkbox = (props: CheckboxProps): JSX.Element => {
/>
<span
className={[shared.icon, style.icon, self.indeterminate].join(
" "
" ",
)}
children={<Icon display="block" component={coreIcons.dash} />}
/>
Expand Down
17 changes: 13 additions & 4 deletions core/src/checkbox/outset.module.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
.input {
transition: background-color 0.1s, box-shadow 0.1s, outline 0.2s ease-out;
transition:
background-color 0.1s,
box-shadow 0.1s,
outline 0.2s ease-out;
border: solid 1px transparent;
--shadow-size: 0px 0.5px 2px;
--inset-shadow: inset 0px 1px 0px;
Expand All @@ -10,7 +13,9 @@
:global(.light) .input {
--shadow: var(--shadow-size) rgba(0, 0, 0, 0.1);
background-color: var(--gray-0);
box-shadow: var(--shadow), var(--inset-shadow) var(--white);
box-shadow:
var(--shadow),
var(--inset-shadow) var(--white);
border-color: var(--gray-2);
}
:global(.light) .input:hover {
Expand All @@ -24,7 +29,9 @@
:global(.dark) .input {
--shadow: var(--shadow-size) rgba(0, 0, 0, 0.3);
background-color: var(--gray-6);
box-shadow: var(--shadow), var(--inset-shadow) var(--gray-5);
box-shadow:
var(--shadow),
var(--inset-shadow) var(--gray-5);
border-color: var(--black);
}
:global(.dark) .input:hover {
Expand All @@ -42,7 +49,9 @@
:global(.dark) .input:checked,
:global(.dark) .input[type="checkbox"]:indeterminate {
background-color: var(--highlight-5);
box-shadow: var(--shadow), var(--inset-shadow) var(--highlight-4);
box-shadow:
var(--shadow),
var(--inset-shadow) var(--highlight-4);
}

:global(.light) .input:checked,
Expand Down
14 changes: 7 additions & 7 deletions core/src/date-input/date-input.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// TODO: Rewrite date input using the new DayPicker component
import { ReactElement } from "react"
import { DayPicker } from "react-day-picker"
import { ReactElement } from "react";
import { DayPicker } from "react-day-picker";

export const DateInput = (): ReactElement => {
return <DayPicker/>
}
export const DateInput = (): ReactElement => {
return <DayPicker />;
};

// import { ReactNode, useState } from "react";
// import { CaptionElementProps, Modifier } from "react-day-picker";
Expand Down Expand Up @@ -122,13 +122,13 @@ export const DateInput = (): ReactElement => {
// /**
// * A date input is a control for users to enter a date, either by typing it or
// * choosing from a pop-up calendar.
// *
// *
// * The Date Input component is based on [React Day Picker][3], as an
// * alternative to the built-in `<Input type="date" />`. It works on
// * [unsupported browsers][2] and can display custom date format (e.g. "dmy" or
// * "mdy"). If you don't need these features, use [Input][1] to have better
// * accessibility support.

// * [1]: /docs/components-input--primary#date
// * [2]: https://caniuse.com/input-datetime
// * [3]: https://react-day-picker.js.org
Expand Down
2 changes: 1 addition & 1 deletion core/src/dialog/native/alert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const dialogAlert = (
message: React.ReactNode,
options?: {
width?: DialogProps["width"];
}
},
): Promise<void> => {
return new Promise((resolve) => {
renderDialog((unmount) => (
Expand Down
2 changes: 1 addition & 1 deletion core/src/dialog/native/confirm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const dialogConfirm = (
message: React.ReactNode,
options?: {
width?: DialogProps["width"];
}
},
): Promise<boolean> => {
return new Promise((resolve) => {
renderDialog((unmount) => (
Expand Down
2 changes: 1 addition & 1 deletion core/src/dialog/native/prompt.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export const dialogPrompt = (
options?: {
width?: Props["width"];
rows?: Props["rows"];
}
},
): Promise<string | null> => {
return new Promise((resolve) => {
renderDialog((unmount) => (
Expand Down
2 changes: 1 addition & 1 deletion core/src/form/field.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ export const FormField = (props: Props): JSX.Element => {
{label}
</span>,
<DivPx size={8} />,
<span className={s.input}>{children}</span>
<span className={s.input}>{children}</span>,
);
};
2 changes: 1 addition & 1 deletion core/src/icons/blank-icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ import { GenIcon, IconBaseProps, IconType } from "react-icons";

export const BlankIcon: IconType = (props: IconBaseProps): JSX.Element => {
return GenIcon({ tag: "svg", attr: { viewBox: "0 0 16 16" }, child: [] })(
props
props,
);
};
4 changes: 3 additions & 1 deletion core/src/input/flat.module.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
.main {
transition: background-color 0.1s, outline 0.2s ease-out;
transition:
background-color 0.1s,
outline 0.2s ease-out;

/* Pretty much nothing in normal state */
text-align: inherit;
Expand Down
2 changes: 1 addition & 1 deletion core/src/input/input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ const validate = (props: InputProps): void => {

const inputRender = (
props: InputProps,
ref: React.ForwardedRef<HTMLInputElement>
ref: React.ForwardedRef<HTMLInputElement>,
): JSX.Element => {
validate(props);
const size = props.size ?? Input.sizes.medium;
Expand Down
4 changes: 3 additions & 1 deletion core/src/input/outset.module.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
.main {
transition: background-color 0.1s, outline 0.2s ease-out;
transition:
background-color 0.1s,
outline 0.2s ease-out;

border-width: 1px;
border-style: solid;
Expand Down
2 changes: 1 addition & 1 deletion core/src/pagination/pagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const Pagination = (props: PaginationProps): JSX.Element => {
await setValueOrg(value);
setBusy(false);
},
[setValueOrg, max, min]
[setValueOrg, max, min],
);

return (
Expand Down
2 changes: 1 addition & 1 deletion core/src/pane/pane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@ export const Pane = (props: Props): JSX.Element => (

Pane.styles = {
outset: [border.px1, background.strong, border.strong, shadow.boxWeak].join(
" "
" ",
),
};
2 changes: 1 addition & 1 deletion core/src/progress/circle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const getViewBox = (strokeWidth: number) => {
const getStroke = (props: ProgressCircleProps) => {
const width = Math.min(
MIN_STROKE_WIDTH,
(STROKE_WIDTH * SIZE_LARGE) / props.size
(STROKE_WIDTH * SIZE_LARGE) / props.size,
);
const value = props.value === "indeterminate" ? 0.25 : props.value;
const offset = PATH_LENGTH - PATH_LENGTH * value;
Expand Down
2 changes: 1 addition & 1 deletion core/src/step/step.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export const Steps = (props: Props): JSX.Element => {
index={index}
current={props.current}
/>,
<Divider key={`${index}-divider`} />
<Divider key={`${index}-divider`} />,
);
});
children.pop();
Expand Down
4 changes: 0 additions & 4 deletions core/src/tab/tab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,7 @@ const outsetStyle: TabStyle = {
inactive: s.outsetInactive,
renderContent: (children, props) => (
<Pane
// eslint-disable-next-line react/prop-types
noPadding={props.noPadding}
// eslint-disable-next-line react/prop-types
fullHeight={props.fullHeight}
children={children}
/>
Expand All @@ -167,9 +165,7 @@ const flatStyle: TabStyle = {
renderContent: (children, props) => (
<div
className={[
// eslint-disable-next-line react/prop-types
props.noPadding ? "" : s.flatPadding,
// eslint-disable-next-line react/prop-types
props.fullHeight ? s.flatFullHeight : "",
].join(" ")}
children={children}
Expand Down
35 changes: 17 additions & 18 deletions core/src/table/actions/actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,26 @@ import s from "./actions.module.css";

const renderActions =
<R,>(props: TableProps<R>, state: TableState) =>
(_row: R, _index: number, rowKey: string): JSX.Element =>
(
<div className={s.container}>
{props.selectable !== undefined && (
<TableSelectableControl
rowKey={rowKey}
selectable={props.selectable}
/>
)}
{props.expandable !== undefined && (
<TableExpandableControl
rowKey={rowKey}
expandable={state.expandable}
/>
)}
</div>
);
(_row: R, _index: number, rowKey: string): JSX.Element => (
<div className={s.container}>
{props.selectable !== undefined && (
<TableSelectableControl
rowKey={rowKey}
selectable={props.selectable}
/>
)}
{props.expandable !== undefined && (
<TableExpandableControl
rowKey={rowKey}
expandable={state.expandable}
/>
)}
</div>
);

export const getTableActionsColumn = <R,>(
props: TableProps<R>,
state: TableState
state: TableState,
): TableColumn<R> => ({
className: s.column,
title: "",
Expand Down
2 changes: 1 addition & 1 deletion core/src/table/actions/selectable/state.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export interface TableSelectableProps<T extends TableSelected> {

export const isTableRowSelected = (
selected: TableSelected | undefined,
rowKey: string
rowKey: string,
): boolean => {
if (selected === undefined) return false;
if (typeof selected === "string") return selected === rowKey;
Expand Down
8 changes: 5 additions & 3 deletions core/src/table/body/cell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ interface Props<R> {
export const TableBodyCell = <R,>(props: Props<R>): JSX.Element => {
const { column, row } = props;
const children =
typeof column.render === "function"
? <>{column.render(row, props.rowIndex, props.rowKey)}</> // Render function
: <>{row[column.render]}</>; // Accessor
typeof column.render === "function" ? (
<>{column.render(row, props.rowIndex, props.rowKey)}</> // Render function
) : (
<>{row[column.render]}</>
); // Accessor
const columnMeta = props.tableState.columnMetaMap.get(props.columnIndex);
return (
<td
Expand Down
2 changes: 1 addition & 1 deletion core/src/table/column/column.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export type TableColumnMetaMap = Map<number, TableColumnMeta>;
// These meta info can be calculated in each cell, but we put it here so it
// can be calculated once for each table
export const getTableColumnMetaMap = <R>(
props: TableProps<R>
props: TableProps<R>,
): TableColumnMetaMap => {
// We only have fixed meta for now. If we have more in the future, we should
// merge them here
Expand Down
2 changes: 1 addition & 1 deletion core/src/table/fixed/fixed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { TableProps } from "../table";
import s from "./fixed.module.css";

export const getTableFixedMetaMap = <R>(
props: TableProps<R>
props: TableProps<R>,
): TableColumnMetaMap => {
const map: TableColumnMetaMap = new Map();
if (props.fixed === undefined) return map;
Expand Down
Loading

0 comments on commit 588f56a

Please sign in to comment.