Skip to content

Commit

Permalink
Tweak Prettier config & add eslint-plugin-tailwindcss
Browse files Browse the repository at this point in the history
  • Loading branch information
benscobie committed Aug 6, 2024
1 parent 95e25e0 commit 79209c2
Show file tree
Hide file tree
Showing 54 changed files with 1,003 additions and 976 deletions.
6 changes: 5 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
{
"extends": ["next/core-web-vitals", "prettier"]
"extends": [
"next/core-web-vitals",
"prettier",
"plugin:tailwindcss/recommended"
]
}
8 changes: 4 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Build

on:
push:
branches: ["master"]
branches: ['master']
pull_request:
branches: ["master"]
branches: ['master']

jobs:
build:
Expand All @@ -18,7 +18,7 @@ jobs:
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "20"
node-version: '20'
cache: yarn

- name: Restore cache
Expand Down Expand Up @@ -61,4 +61,4 @@ jobs:
push: true
tags: benscobie/student-loan-repayment-calculator:latest
context: .
file: "docker/Dockerfile.linux.amd64"
file: 'docker/Dockerfile.linux.amd64'
10 changes: 5 additions & 5 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"
name: 'CodeQL'

on:
push:
branches: ["master"]
branches: ['master']
pull_request:
# The branches below must be a subset of the branches above
branches: ["master"]
branches: ['master']
schedule:
- cron: "42 15 * * 0"
- cron: '42 15 * * 0'

jobs:
analyze:
Expand All @@ -32,7 +32,7 @@ jobs:
strategy:
fail-fast: false
matrix:
language: ["javascript"]
language: ['javascript']
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support

Expand Down
5 changes: 5 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"semi": false,
"singleQuote": true,
"trailingComma": "all"
}
2 changes: 1 addition & 1 deletion .yarn/releases/yarn-4.3.1.cjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
![License MIT](https://img.shields.io/badge/license-MIT-blue.svg) [![](https://img.shields.io/docker/pulls/benscobie/student-loan-repayment-calculator.svg)](https://hub.docker.com/r/benscobie/student-loan-repayment-calculator "DockerHub")
![License MIT](https://img.shields.io/badge/license-MIT-blue.svg) [![](https://img.shields.io/docker/pulls/benscobie/student-loan-repayment-calculator.svg)](https://hub.docker.com/r/benscobie/student-loan-repayment-calculator 'DockerHub')

# Student Loan Repayment Calculator

Expand Down
22 changes: 11 additions & 11 deletions api/models/projection.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import LoanType from "../../models/loanType";
import RepaymentStatus from "../../models/repaymentStatus";
import LoanType from '../../models/loanType'
import RepaymentStatus from '../../models/repaymentStatus'

export default interface Projection {
repaymentStatus: RepaymentStatus;
loanType: LoanType;
debtRemaining: number;
interestRate: number;
paid: number;
interestApplied: number;
totalPaid: number;
totalInterestApplied: number;
threshold: number;
repaymentStatus: RepaymentStatus
loanType: LoanType
debtRemaining: number
interestRate: number
paid: number
interestApplied: number
totalPaid: number
totalInterestApplied: number
threshold: number
}
22 changes: 11 additions & 11 deletions api/models/result.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { DateTime } from "luxon";
import Projection from "./projection";
import { DateTime } from 'luxon'
import Projection from './projection'

export default interface Result {
period: number;
periodDate: DateTime;
salary: number;
projections: Projection[];
aggregatedDebtRemaining: number;
aggregatedPaidInPeriod: number;
aggregatedInterestAppliedInPeriod: number;
aggregatedTotalInterestApplied: number;
aggregatedTotalPaid: number;
period: number
periodDate: DateTime
salary: number
projections: Projection[]
aggregatedDebtRemaining: number
aggregatedPaidInPeriod: number
aggregatedInterestAppliedInPeriod: number
aggregatedTotalInterestApplied: number
aggregatedTotalPaid: number
}
14 changes: 7 additions & 7 deletions api/models/results.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { DateTime } from "luxon";
import Result from "./result";
import { DateTime } from 'luxon'
import Result from './result'

export interface Results {
results: Result[];
debtClearedDate: DateTime;
debtClearedNumberOfPeriods: number;
totalPaid: number;
totalInterestApplied: number;
results: Result[]
debtClearedDate: DateTime
debtClearedNumberOfPeriods: number
totalPaid: number
totalInterestApplied: number
}
18 changes: 9 additions & 9 deletions components/Layout.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { ReactNode } from "react";
import Footer from "./ui/organisms/Footer";
import Header from "./ui/organisms/Header";
import Head from "next/head";
import { ReactNode } from 'react'
import Footer from './ui/organisms/Footer'
import Header from './ui/organisms/Header'
import Head from 'next/head'

interface LayoutProps {
children?: ReactNode | undefined;
className?: string;
children?: ReactNode | undefined
className?: string
}

function Layout({ children, className }: LayoutProps) {
Expand Down Expand Up @@ -33,11 +33,11 @@ function Layout({ children, className }: LayoutProps) {
</Head>
<div className={className}>
<Header />
<main className="container mx-auto max-w-7xl my-8">{children}</main>
<main className="container mx-auto my-8 max-w-7xl">{children}</main>
<Footer />
</div>
</>
);
)
}

export default Layout;
export default Layout
46 changes: 23 additions & 23 deletions components/ui/atoms/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
import classNames from "classnames";
import { useRef } from "react";
import { twMerge } from "tailwind-merge";
import classNames from 'classnames'
import { useRef } from 'react'
import { twMerge } from 'tailwind-merge'

interface ButtonProps
extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, "style"> {
id: string;
disabled?: boolean;
style: "primary" | "secondary";
children?: React.ReactNode;
extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'style'> {
id: string
disabled?: boolean
style: 'primary' | 'secondary'
children?: React.ReactNode
}

const Button = (props: ButtonProps) => {
const {
id,
type = "button",
type = 'button',
disabled = false,
style,
className,
children,
...rest
} = props;
} = props

const inputRef = useRef(null);
const inputRef = useRef(null)

const btnClass = classNames("rounded-lg text-sm px-5 py-2.5", {
"text-white border border-sky-600 bg-sky-600": style == "primary",
"hover:bg-sky-700 hover:border-sky-700 focus:ring-2 focus:ring-sky-500 focus:outline-none":
style == "primary" && !disabled,
const btnClass = classNames('rounded-lg text-sm px-5 py-2.5', {
'text-white border border-sky-600 bg-sky-600': style == 'primary',
'hover:bg-sky-700 hover:border-sky-700 focus:ring-2 focus:ring-sky-500 focus:outline-none':
style == 'primary' && !disabled,

"text-sky-700 border border-sky-600": style == "secondary",
"hover:bg-sky-700 hover:text-white focus:ring-2 focus:ring-slate-300 focus:outline-none":
style == "secondary" && !disabled,
'text-sky-700 border border-sky-600': style == 'secondary',
'hover:bg-sky-700 hover:text-white focus:ring-2 focus:ring-slate-300 focus:outline-none':
style == 'secondary' && !disabled,

"opacity-50 cursor-not-allowed": disabled,
});
'opacity-50 cursor-not-allowed': disabled,
})

return (
<button
Expand All @@ -46,7 +46,7 @@ const Button = (props: ButtonProps) => {
>
{children}
</button>
);
};
)
}

export default Button;
export default Button
38 changes: 19 additions & 19 deletions components/ui/atoms/Checkbox.tsx
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
import { forwardRef } from "react";
import { forwardRef } from 'react'

interface CheckboxProps extends React.InputHTMLAttributes<HTMLInputElement> {
id: string;
placeholder?: string;
label: string;
type?: string;
error?: boolean;
errorText?: string;
required?: boolean;
children?: React.ReactNode;
id: string
placeholder?: string
label: string
type?: string
error?: boolean
errorText?: string
required?: boolean
children?: React.ReactNode
}

const Checkbox = forwardRef<HTMLInputElement, CheckboxProps>(
function InputGroup(props: CheckboxProps, ref) {
const {
id,
label = "",
label = '',
error = false,
errorText = "",
errorText = '',
required = false,
...rest
} = props;
} = props

return (
<>
<input
ref={ref}
type="checkbox"
className={`border bg-gray-50 text-gray-900 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 p-2.5 font-light text-sm w-4 h-4 rounded ${
error ? "border-red-600" : "border-gray-300"
className={`size-4 rounded border bg-gray-50 p-2.5 text-sm font-light text-gray-900 focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-500 ${
error ? 'border-red-600' : 'border-gray-300'
}`}
id={id}
{...rest}
/>
<label htmlFor={id} className="ml-2 mb-1">
<label htmlFor={id} className="mb-1 ml-2">
{label} {required && <span className="text-red-600">*</span>}
</label>
{errorText && (
<p className="text-xs pl-2 text-red-600 mt-1">{errorText}</p>
<p className="mt-1 pl-2 text-xs text-red-600">{errorText}</p>
)}
</>
);
)
},
);
)

export default Checkbox;
export default Checkbox
16 changes: 8 additions & 8 deletions components/ui/atoms/Container.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import classNames from "classnames";
import classNames from 'classnames'

export type ContainerProps = {
children?: React.ReactNode;
className?: string;
};
children?: React.ReactNode
className?: string
}

export const Container = ({ className, children }: ContainerProps) => {
return (
<div
className={classNames(
"mx-0 p-8 sm:mx-8 max-w-7xl bg-white shadow-lg",
className
'mx-0 p-8 sm:mx-8 max-w-7xl bg-white shadow-lg',
className,
)}
>
{children}
</div>
);
};
)
}
Loading

0 comments on commit 79209c2

Please sign in to comment.