Skip to content

Commit

Permalink
Merge branch 'main' into biome
Browse files Browse the repository at this point in the history
  • Loading branch information
jlsnow301 committed Nov 13, 2024
2 parents 654d3d4 + c0b1698 commit 3525c36
Show file tree
Hide file tree
Showing 104 changed files with 608 additions and 3,866 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,8 @@
"[yaml][markdown][html][scss]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[yaml][markdown][html][scss]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"typescript.tsdk": "node_modules/typescript/lib"
}
2 changes: 1 addition & 1 deletion lib/common/color.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export class Color {
(c2.r - c1.r) * n + c1.r,
(c2.g - c1.g) * n + c1.g,
(c2.b - c1.b) * n + c1.b,
(c2.a - c1.a) * n + c1.a,
(c2.a - c1.a) * n + c1.a
);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/common/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const globalEvents = new EventEmitter();
let ignoreWindowFocus = false;

export const setupGlobalEvents = (
options: { ignoreWindowFocus?: boolean } = {},
options: { ignoreWindowFocus?: boolean } = {}
): void => {
ignoreWindowFocus = !!options.ignoreWindowFocus;
};
Expand Down
6 changes: 3 additions & 3 deletions lib/common/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const SI_BASE_INDEX = SI_SYMBOLS.indexOf(' ');
export function formatSiUnit(
value: number,
minBase1000 = -SI_BASE_INDEX,
unit = '',
unit = ''
): string {
if (!Number.isFinite(value)) {
return value.toString();
Expand Down Expand Up @@ -121,7 +121,7 @@ const SI_BASE_TEN_UNITS = [
export function formatSiBaseTenUnit(
value: number,
minBase1000 = 0,
unit = '',
unit = ''
): string {
if (!Number.isFinite(value)) {
return 'NaN';
Expand All @@ -145,7 +145,7 @@ export function formatSiBaseTenUnit(
*/
export function formatTime(
val: number,
formatType: 'short' | 'default' = 'default',
formatType: 'short' | 'default' = 'default'
): string {
const totalSeconds = Math.floor(val / 10);
const hours = Math.floor(totalSeconds / 3600);
Expand Down
2 changes: 1 addition & 1 deletion lib/common/math.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export function inRange(value: number, range: number[]): boolean {
*/
export function keyOfMatchingRange(
value: number,
ranges: Record<string, any>,
ranges: Record<string, any>
): string | undefined {
for (const rangeName of Object.keys(ranges)) {
const range = ranges[rangeName];
Expand Down
2 changes: 1 addition & 1 deletion lib/common/react.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export function normalizeChildren<T>(children: T | T[]): T[] {
*/
export function shallowDiffers(
a: Record<string, any>,
b: Record<string, any>,
b: Record<string, any>
): boolean {
let i: string;
for (i in a) {
Expand Down
4 changes: 2 additions & 2 deletions lib/common/string.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/
export function createSearch<TObj>(
searchText: string,
stringifier = (obj: TObj) => JSON.stringify(obj),
stringifier = (obj: TObj) => JSON.stringify(obj)
): (obj: TObj) => boolean {
const preparedSearchText = searchText.toLowerCase().trim();

Expand Down Expand Up @@ -190,7 +190,7 @@ export function decodeHtmlEntities(str: string): string {
// Basic entities
.replace(
/&(nbsp|amp|quot|lt|gt|apos);/g,
(_match, entity) => TRANSLATIONS[entity],
(_match, entity) => TRANSLATIONS[entity]
)
// Decimal entities
.replace(/&#?([0-9]+);/gi, (_match, numStr) => {
Expand Down
6 changes: 3 additions & 3 deletions lib/common/timer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
export function debounce<F extends (...args: any[]) => any>(
fn: F,
time: number,
immediate = false,
immediate = false
): (...args: Parameters<F>) => void {
let timeout: ReturnType<typeof setTimeout> | null;
return (...args: Parameters<F>) => {
Expand All @@ -32,7 +32,7 @@ export function debounce<F extends (...args: any[]) => any>(
*/
export function throttle<F extends (...args: any[]) => any>(
fn: F,
time: number,
time: number
): (...args: Parameters<F>) => void {
let previouslyRun: number | null;
let queuedToRun: ReturnType<typeof setTimeout> | null;
Expand All @@ -47,7 +47,7 @@ export function throttle<F extends (...args: any[]) => any>(
} else {
queuedToRun = setTimeout(
() => invokeFn(...args),
time - (now - (previouslyRun ?? 0)),
time - (now - (previouslyRun ?? 0))
);
}
};
Expand Down
3 changes: 1 addition & 2 deletions lib/components/BlockQuote.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { classes } from '../common/react';
import styles from '../styles/components/BlockQuote.module.scss';
import { Box, type BoxProps } from './Box';

export function BlockQuote(props: BoxProps) {
const { className, ...rest } = props;

return <Box className={classes([styles.blockQuote, className])} {...rest} />;
return <Box className={classes(['BlockQuote', className])} {...rest} />;
}
2 changes: 1 addition & 1 deletion lib/components/Box.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,6 @@ export function Box(props: BoxProps & DangerDoNotUse) {
...computedProps,
className: computedClassName,
},
children,
children
);
}
39 changes: 21 additions & 18 deletions lib/components/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ import {
useRef,
useState,
} from 'react';

import { KEY, isEscape } from '../common/keys';
import { type BooleanLike, classes } from '../common/react';
import styles from '../styles/components/Button.module.scss';
import {
Box,
type BoxProps,
Expand Down Expand Up @@ -111,19 +109,20 @@ export function Button(props: Props) {
let buttonContent = (
<div
className={classes([
styles.button,
fluid && styles.fluid,
disabled && styles.disabled,
selected && styles.selected,
circular && styles.circular,
compact && styles.compact,
verticalAlignContent && styles.flex,
verticalAlignContent && fluid && styles.flex__fluid,
'Button',
fluid && 'Button--fluid',
disabled && 'Button--disabled',
selected && 'Button--selected',
circular && 'Button--circular',
compact && 'Button--compact',
iconPosition && `Button--iconPosition--${iconPosition}`,
verticalAlignContent && 'Button--flex',
verticalAlignContent && fluid && 'Button--flex--fluid',
verticalAlignContent &&
styles[`verticalAlignContent__${verticalAlignContent}`],
`Button--verticalAlignContent--${verticalAlignContent}`,
color && typeof color === 'string'
? styles[`color__${color}`]
: styles.color__default,
? `Button--color--${color}`
: 'Button--color--default',
className,
computeBoxClassName(rest),
])}
Expand Down Expand Up @@ -154,7 +153,7 @@ export function Button(props: Props) {
}}
{...computeBoxProps(rest)}
>
<div className={styles.content}>
<div className="Button__content">
{icon && iconPosition !== 'right' && (
<Icon
mr={toDisplay ? 1 : 0}
Expand All @@ -169,7 +168,10 @@ export function Button(props: Props) {
toDisplay
) : (
<span
className={classes([styles.ellipsis, icon && styles.textMargin])}
className={classes([
'Button--ellipsis',
icon && 'Button__textMargin',
])}
>
{toDisplay}
</span>
Expand Down Expand Up @@ -333,9 +335,10 @@ function ButtonInput(props: InputProps) {
let buttonContent = (
<Box
className={classes([
styles.button,
fluid && styles.fluid,
styles[`color__${color}`],
'Button',
fluid && 'Button--fluid',
disabled && 'Button--disabled',
`Button--color--${color}`,
])}
{...rest}
onClick={() => setInInput(true)}
Expand Down
7 changes: 1 addition & 6 deletions lib/components/ColorBox.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { ReactNode } from 'react';

import { classes } from '../common/react';
import styles from '../styles/components/ColorBox.module.scss';
import { type BoxProps, computeBoxClassName, computeBoxProps } from './Box';

type Props = {
Expand All @@ -16,11 +15,7 @@ export function ColorBox(props: Props) {

return (
<div
className={classes([
styles.colorBox,
className,
computeBoxClassName(rest),
])}
className={classes(['ColorBox', className, computeBoxClassName(rest)])}
{...computeBoxProps(rest)}
>
{content || ''}
Expand Down
15 changes: 7 additions & 8 deletions lib/components/Dialog.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import styles from '../styles/components/Dialog.module.scss';
import { Box } from './Box';
import { Button } from './Button';

Expand All @@ -13,10 +12,10 @@ type DialogProps = {
export function Dialog(props: DialogProps) {
const { title, onClose, children, width, height } = props;
return (
<div className={styles.dialog}>
<Box className={styles.content} width={width || '370px'} height={height}>
<div className={styles.header}>
<div className={styles.title}>{title}</div>
<div className="Dialog">
<Box className="Dialog__content" width={width || '370px'} height={height}>
<div className="Dialog__header">
<div className="Dialog__title">{title}</div>
<Box mr={2}>
<Button
mr="-3px"
Expand Down Expand Up @@ -47,7 +46,7 @@ function DialogButton(props: DialogButtonProps) {
return (
<Button
onClick={onClick}
className={styles.button}
className="Dialog__button"
verticalAlignContent="middle"
>
{children}
Expand All @@ -68,10 +67,10 @@ export function UnsavedChangesDialog(props: UnsavedChangesDialogProps) {
const { documentName, onSave, onDiscard, onClose } = props;
return (
<Dialog title="Notepad" onClose={onClose}>
<div className={styles.body}>
<div className="Dialog__body">
Do you want to save changes to {documentName}?
</div>
<div className={styles.footer}>
<div className="Dialog__footer">
<DialogButton onClick={onSave}>Save</DialogButton>
<DialogButton onClick={onDiscard}>Don&apos;t Save</DialogButton>
<DialogButton onClick={onClose}>Cancel</DialogButton>
Expand Down
4 changes: 2 additions & 2 deletions lib/components/Dimmer.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { classes } from '../common/react';
import styles from '../styles/components/Dimmer.module.scss';

import { Box, type BoxProps } from './Box';

export function Dimmer(props: BoxProps) {
const { className, children, ...rest } = props;

return (
<Box className={classes([styles.dimmer, className])} {...rest}>
<Box className={classes(['Dimmer', className])} {...rest}>
<div className="Dimmer__inner">{children}</div>
</Box>
);
Expand Down
6 changes: 3 additions & 3 deletions lib/components/Divider.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { classes } from '../common/react';
import styles from '../styles/components/Divider.module.scss';

type Props = Partial<{
hidden: boolean;
Expand All @@ -12,8 +11,9 @@ export function Divider(props: Props) {
return (
<div
className={classes([
hidden && styles.hidden,
vertical ? styles.vertical : styles.horizontal,
'Divider',
hidden && 'Divider--hidden',
vertical ? 'Divider--vertical' : 'Divider--horizontal',
])}
/>
);
Expand Down
12 changes: 8 additions & 4 deletions lib/components/Flex.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { classes } from '../common/react';
import styles from '../styles/components/Flex.module.scss';

import {
type BoxProps,
computeBoxClassName,
Expand Down Expand Up @@ -65,8 +65,8 @@ export type FlexProps = Partial<{

export function computeFlexClassName(props: FlexProps) {
return classes([
styles.flex,
props.inline && styles.inline,
'Flex',
props.inline && 'Flex--inline',
computeBoxClassName(props),
]);
}
Expand Down Expand Up @@ -96,6 +96,10 @@ export function Flex(props) {
);
}

export const computeFlexItemClassName = (props: FlexItemProps) => {
return classes(['Flex__item', computeBoxClassName(props)]);
};

export type FlexItemProps = Partial<{
/** This allows the default alignment (or the one specified by align-items) to be overridden for individual flex items. */
align: string | boolean;
Expand Down Expand Up @@ -155,7 +159,7 @@ function FlexItem(props) {
const { className, ...rest } = props;
return (
<div
className={classes([className, computeBoxClassName(props)])}
className={classes([className, computeFlexItemClassName(props)])}
{...computeFlexItemProps(rest)}
/>
);
Expand Down
9 changes: 2 additions & 7 deletions lib/components/Icon.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { CSSProperties, ReactNode } from 'react';

import { type BooleanLike, classes } from '../common/react';
import style from '../styles/components/Icon.module.scss';
import { type BoxProps, computeBoxClassName, computeBoxProps } from './Box';

type Props = {
Expand Down Expand Up @@ -59,7 +58,7 @@ export function Icon(props: Props) {
return (
<i
className={classes([
style.icon,
'Icon',
iconClass,
className,
computeBoxClassName(rest),
Expand All @@ -80,11 +79,7 @@ export function IconStack(props: IconStackProps) {
const { className, children, ...rest } = props;
return (
<span
className={classes([
style.iconStack,
className,
computeBoxClassName(rest),
])}
className={classes(['IconStack', className, computeBoxClassName(rest)])}
{...computeBoxProps(rest)}
>
{children}
Expand Down
Loading

0 comments on commit 3525c36

Please sign in to comment.