Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Functional calculator #80

Closed
wants to merge 14 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@
"@rooks/use-raf": "^4.11.0",
"clsx": "^1.1.1",
"date-fns": "^2.21.1",
"framer-motion": "^4.1.4",
"framer-motion": "^4.1.8",
"immer": "^9.0.1",
"jotai": "^0.16.0",
"jotai": "^0.16.2",
"preact": "^10.5.13",
"react-rnd": "^10.2.4"
},
"devDependencies": {
"@preact/preset-vite": "^2.0.1",
"@preact/preset-vite": "^2.1.0",
"@types/react": "^17.0.3",
"autoprefixer": "^10.2.5",
"sass": "^1.32.8",
"sass": "^1.32.11",
"typescript": "^4.2.4",
"typescript-plugin-css-modules": "^3.2.0",
"vite": "^2.2.1",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { mdiClose, mdiDivision, mdiMinus, mdiPercentOutline, mdiPlusMinusVariant } from '@mdi/js';
import { mdiClose, mdiDivision, mdiEqual, mdiMinus, mdiPlus, mdiPlusMinusVariant } from '@mdi/js';
import clsx from 'clsx';
import { AppIcon } from '__/components/utils/AppIcon';
import { ButtonBase } from '__/components/utils/ButtonBase';
Expand All @@ -11,9 +11,7 @@ export const CalculatorButtonsArea = () => {
<ButtonBase class={css.topRowButton}>
<AppIcon path={mdiPlusMinusVariant} />
</ButtonBase>
<ButtonBase class={css.topRowButton}>
<AppIcon path={mdiPercentOutline} />
</ButtonBase>
<ButtonBase class={css.topRowButton}>%</ButtonBase>
<ButtonBase class={css.operationButton}>
<AppIcon path={mdiDivision} />
</ButtonBase>
Expand All @@ -35,7 +33,9 @@ export const CalculatorButtonsArea = () => {
<ButtonBase class={css.numberButton}>1</ButtonBase>
<ButtonBase class={css.numberButton}>2</ButtonBase>
<ButtonBase class={css.numberButton}>3</ButtonBase>
<ButtonBase class={css.operationButton}>+</ButtonBase>
<ButtonBase class={css.operationButton}>
<AppIcon path={mdiPlus} />
</ButtonBase>

<ButtonBase
class={clsx(css.numberButton, css.curvedBottomLeftButton)}
Expand All @@ -44,7 +44,9 @@ export const CalculatorButtonsArea = () => {
0
</ButtonBase>
<ButtonBase class={css.numberButton}>,</ButtonBase>
<ButtonBase class={clsx(css.operationButton, css.curvedBottomRightButton)}>=</ButtonBase>
<ButtonBase class={clsx(css.operationButton, css.curvedBottomRightButton)}>
<AppIcon path={mdiEqual} />
</ButtonBase>
</section>
);
};
6 changes: 1 addition & 5 deletions src/components/topbar/TopBarTime.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,5 @@ export const TopBarTime = () => {

useInterval(() => setTime(new Date()), 2000);

return (
<div style={{ margin: '0 0.5rem' }}>
{format(time, 'EEE MMM dd')}&nbsp; {format(time, 'h:mm aa')}
</div>
);
return <div style={{ margin: '0 0.5rem' }}>{format(time, 'EEE MMM dd h:mm aa')}</div>;
};
5 changes: 5 additions & 0 deletions src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,25 @@ type ObjectKeys<Obj> = Obj extends object
? string[]
: never;

/** Object.keys now infers the union types from the object rather than `string[] */
interface ObjectConstructor {
keys<ObjectType>(o: ObjectType): ObjectKeys<ObjectType>;
}

/** localstorage.getItem<Type>('') return the `Type` rather than string */
interface Storage {
getItem<T extends string>(key: string): T | null;
}

/** Retrieves element type from an array */
type Unpacked<ArrayLike> = ArrayLike extends (infer RootType)[] ? RootType : ArrayLike;

/** Retrieves Root type from a promise or a function returning a promise */
type Unpromisify<PromiseLike> = PromiseLike extends Promise<infer RootType>
? RootType
: PromiseLike;

/** Override to use the beautiful `class` instead of `className` when preact and @types/react are both in the soup */
declare namespace React {
interface HTMLAttributes<T> {
class?: string;
Expand Down