Skip to content
This repository has been archived by the owner on Dec 19, 2024. It is now read-only.

Refactor input styling #57

Merged
merged 22 commits into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
60b2162
refactor: use default input styling for CustomInput
galenwinsor Jun 27, 2024
41d5b35
feat: labels for inputs and textarea
galenwinsor Jun 27, 2024
be8135c
fix: update buttons
galenwinsor Jun 27, 2024
a8da686
Merge branch 'main' into refactor-input-styling
galenwinsor Jun 27, 2024
dcd3ca4
Merge branch 'refactor-input-styling' into refactor-download-modal-bu…
galenwinsor Jun 27, 2024
81aff0e
fix: lock file
galenwinsor Jun 27, 2024
2673d06
Merge branch 'refactor-input-styling' into refactor-download-modal-bu…
galenwinsor Jun 27, 2024
10fbfa4
refactor: checkbox and table styling
galenwinsor Jun 27, 2024
f4f5668
fix: no scrollbar
galenwinsor Jun 27, 2024
ca6d15f
fix: max-w-1000px causes modal to be too small
galenwinsor Jun 27, 2024
f5b05cd
fix: error message color and size
galenwinsor Jun 27, 2024
30debd7
feat: add icons for project aims
galenwinsor Jun 27, 2024
b2e272d
Merge pull request #58 from brown-ccv/refactor-download-modal-button
galenwinsor Jun 28, 2024
95c270a
Merge pull request #62 from brown-ccv/feat-aims-icons
galenwinsor Jun 28, 2024
21a7ec3
Merge pull request #61 from brown-ccv/fix-error-messages
galenwinsor Jun 28, 2024
a8a59b1
Merge pull request #59 from brown-ccv/refactor-checkbox-styling
galenwinsor Jun 28, 2024
eeb02ab
refactor: a bunch of style code cleanup
galenwinsor Jun 28, 2024
47b2427
Merge pull request #64 from brown-ccv/chore-style-refactoring
galenwinsor Jul 1, 2024
7483d1a
Merge branch 'main' into refactor-input-styling
hetd54 Jul 1, 2024
c886eca
fix: divider full width
galenwinsor Jul 1, 2024
cd6393c
style: set width of date container to align items better
hetd54 Jul 1, 2024
d9cb5ca
Merge branch 'refactor-input-styling' of https://github.com/brown-ccv…
hetd54 Jul 1, 2024
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
18,657 changes: 18,657 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"start": "astro dev",
"build": "astro check && astro build",
"preview": "astro preview",
"astro": "astro"
"astro": "astro",
"check": "astro check"
},
"dependencies": {
"@astrojs/check": "^0.5.3",
Expand Down
15 changes: 15 additions & 0 deletions src/components/Button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React, { type ReactNode } from "react"

interface ButtonProps
extends React.PropsWithChildren<React.ButtonHTMLAttributes<HTMLButtonElement>> {
icon?: ReactNode
}

export default function Button({ icon, children, ...delegated }: ButtonProps) {
return (
<button className="bg-primary-500" {...delegated}>
{icon}
<span>{children}</span>
</button>
)
}
8 changes: 2 additions & 6 deletions src/components/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,11 @@ const Card: React.FC<CardProps> = ({ position, image, title, name, institution }
const link = image?.replace("/public", "")
return (
<div
className={`flex flex-row gap-8 ${position % 2 ? "md:flex-row-reverse md:text-right" : ""}`}
className={`flex flex-wrap gap-x-8 ${position % 2 ? "md:flex-row-reverse md:text-right" : ""}`}
>
{image && (
<div>
<img
className="object-cover rounded-full w-64 h-64 min-w-64 min-h-64 hidden md:block"
src={link}
alt={name}
/>
<img className="object-cover rounded-full w-64 h-64" src={link} alt={name} />
</div>
)}
<div>
Expand Down
4 changes: 2 additions & 2 deletions src/components/CardContainer.astro
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ interface PersonProps {
}
---

<div class="flex flex-row items-start space-x-12">
<div class="flex items-start gap-12">
<h2 class={`${color} [writing-mode:vertical-lr] rotate-180`}>{title}</h2>
<div class="flex flex-col space-y-20 flex-1">
<div class="flex flex-col gap-20 flex-1">
{
people.map((person: PersonProps, i: number) => {
return (
Expand Down
9 changes: 4 additions & 5 deletions src/components/CustomInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,19 @@ export const CustomInput = React.forwardRef<
| "valid"
} & ReturnType<UseFormRegister<Inputs>>
>(({ onChange, onBlur, name, label, placeholder, match, errorMessage }, ref) => (
<Form.Field name={label} className="py-2 my-4 mx-2">
<Form.Field name={name} className="flex flex-col gap-2">
<Form.Label>{label}</Form.Label>
<Form.Control asChild>
<input
name={name}
ref={ref}
onChange={onChange}
onBlur={onBlur}
id={label}
className="text-gray-400 text-sm font-medium outline-none border-b-2 w-full"
placeholder={placeholder}
ref={ref}
required
/>
</Form.Control>
<Form.Message className="text-red-600 text-lg" match="valueMissing">
<Form.Message className="text-primary-300" match="valueMissing">
Please enter your {label}
</Form.Message>
{match !== undefined && (
Expand Down
6 changes: 3 additions & 3 deletions src/components/CustomTextarea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,21 @@ export const CustomTextarea = React.forwardRef<
placeholder: string
} & ReturnType<UseFormRegister<Inputs>>
>(({ onChange, onBlur, name, label, placeholder }, ref) => (
<Form.Field name={label} className="py-2 my-4 mx-2">
<Form.Field name={name} className="flex flex-col gap-2">
<Form.Label>{label}</Form.Label>
<Form.Control asChild>
<textarea
rows={4}
name={name}
ref={ref}
onChange={onChange}
onBlur={onBlur}
id={label}
className="text-gray-400 text-sm font-medium outline-none border-b-2 w-full"
placeholder={placeholder}
required
/>
</Form.Control>
<Form.Message className="text-red-600 text-lg" match="valueMissing">
<Form.Message className="text-primary-300" match="valueMissing">
Please enter your {label}
</Form.Message>
</Form.Field>
Expand Down
32 changes: 17 additions & 15 deletions src/components/DataForm.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React, { useState } from "react"
import { set } from "react-hook-form"
import DataTable from "../components/DataTable"
import DownloadModal from "../components/DownloadModal"

Expand All @@ -23,27 +22,30 @@ interface DataFormProps {
}

const DataForm: React.FC<DataFormProps> = ({ allFiles }) => {
const initialFiles = allFiles.map((file) => {
const temp = file.data
return { ...temp, selected: false }
})
const [files, setFiles] = useState(initialFiles)
const [files, setFiles] = useState(
allFiles.map((file) => {
return { ...file.data, selected: false }
})
)

const updateFileList = (fileToUpdate: FileItem, selection: boolean) => {
const filesClone = [...files]
const updatedFiles = filesClone.map((file) => {
if (file.file === fileToUpdate.file) {
file.selected = selection
}
return file
/**
* Given a target file name and new `selected` field for that file, update the matching file object in{@link files}
* with the new value for `selected`.
*/
const updateFileList = ({ file: targetFile }: FileItem, selection: boolean) => {
const updatedFiles = files.map(({ file, selected, ...rest }) => {
return file === targetFile
? { file, selected: selection, ...rest }
: { file, selected, ...rest }
})

setFiles(updatedFiles)
}

return (
<div className="flex flex-col">
<DataTable allFiles={files} updateFileList={updateFileList} />
<div className="space-y-4">
<DownloadModal filesToDownload={files.map((file) => file.file)} />
<DataTable allFiles={files} updateFileList={updateFileList} />
</div>
)
}
Expand Down
52 changes: 27 additions & 25 deletions src/components/DataTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ const DataTable: React.FC<DataTableProps> = ({ allFiles, updateFileList }) => {
return (
<tr key={i}>
<td>
<div className="flex gap-4">
<div className="flex items-center gap-4">
<Checkbox.Root
name={file}
id={file}
className="mx-1 w-6 h-6 border"
className="p-0 w-4 h-4 border"
checked={selected}
onClick={() => handleSelect(selected, i)}
>
Expand All @@ -64,30 +64,32 @@ const DataTable: React.FC<DataTableProps> = ({ allFiles, updateFileList }) => {
})

return (
<table className="table-fixed border-spacing-2">
<thead>
<tr className="bg-neutral-100 text-left text-neutral-900">
<th className="flex w-[200px]">
<Checkbox.Root
name="selectAll"
id="selectAll"
className="mx-1 w-6 h-6 text-neutral-900"
onCheckedChange={handleSelectAll}
>
<Checkbox.Indicator>
<CheckIcon />
</Checkbox.Indicator>
</Checkbox.Root>
File Name
</th>
<th className="w-[200px]">Category</th>
<th>Description</th>
<th>File</th>
</tr>
</thead>
<div className="w-full overflow-x-scroll no-scrollbar">
<table className="table-fixed border-spacing-2">
<thead>
<tr className="bg-neutral-100 text-left text-neutral-900">
<th className="flex items-center w-[200px]">
<Checkbox.Root
name="selectAll"
id="selectAll"
className="p-0 w-4 h-4 text-neutral-900 border"
onCheckedChange={handleSelectAll}
>
<Checkbox.Indicator>
<CheckIcon />
</Checkbox.Indicator>
</Checkbox.Root>
File Name
</th>
<th className="w-[200px]">Category</th>
<th>Description</th>
<th>File</th>
</tr>
</thead>

<tbody>{selectedFiles}</tbody>
</table>
<tbody>{selectedFiles}</tbody>
</table>
</div>
)
}
export default DataTable
Loading