-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* generated types * react components, shelter ui half * updates --------- Co-authored-by: Tom Glaz <tgmessages@gmail.com>
- Loading branch information
1 parent
3897ba9
commit 78ee5fd
Showing
35 changed files
with
608 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
libs/expo/betterangels/src/lib/apollo/graphql/__generated__/types.ts
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"extends": ["plugin:@nx/react", "../../../.eslintrc.json"], | ||
"ignorePatterns": ["!**/*"], | ||
"overrides": [ | ||
{ | ||
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": ["*.ts", "*.tsx"], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": ["*.js", "*.jsx"], | ||
"rules": {} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# react-components | ||
|
||
This library was generated with [Nx](https://nx.dev). | ||
|
||
## Running unit tests | ||
|
||
Run `nx test react-components` to execute the unit tests via [Jest](https://jestjs.io). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* eslint-disable */ | ||
export default { | ||
displayName: 'react-components', | ||
preset: '../../../jest.preset.js', | ||
testEnvironment: 'node', | ||
transform: { | ||
'^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }], | ||
}, | ||
moduleFileExtensions: ['ts', 'js', 'html'], | ||
coverageDirectory: '../../../coverage/libs/react/components', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"name": "react-components", | ||
"$schema": "../../../node_modules/nx/schemas/project-schema.json", | ||
"sourceRoot": "libs/react/components/src", | ||
"projectType": "library", | ||
"tags": [], | ||
"targets": { | ||
"test": { | ||
"executor": "@nx/jest:jest", | ||
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"], | ||
"options": { | ||
"jestConfig": "libs/react/components/jest.config.ts" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './lib'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import clsx from 'clsx'; | ||
import { ButtonHTMLAttributes } from 'react'; | ||
|
||
interface IButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> { | ||
/** | ||
* The size of the button. Determines padding and font size. | ||
* - `sm`: 26px. | ||
* - `md`: Medium size (default). | ||
* - `lg`: Large size. | ||
*/ | ||
size?: 'sm' | 'md' | 'lg'; | ||
/** | ||
* The variant of the button. Determines background and text color. | ||
* - `primary`: primary-20 background, white text. | ||
* - `secondary`: neutral-99 background, primary-20 text. | ||
*/ | ||
variant?: 'primary' | 'secondary'; | ||
} | ||
|
||
export function Button(props: IButtonProps) { | ||
const { size = 'md', variant = 'primary', className, ...rest } = props; | ||
|
||
const sizeClasses = { | ||
sm: 'h-[26px] px-2 text-sm', | ||
md: 'h-[32px] px-4 text-base', | ||
lg: 'h-[40px] px-6 text-lg', | ||
}; | ||
|
||
const variantClasses = { | ||
primary: 'bg-primary-20 text-white', | ||
secondary: 'bg-neutral-99 text-primary-20', | ||
}; | ||
|
||
const buttonClass = clsx( | ||
className, | ||
'font-semibold text-sm focus:outline-none rounded-lg', | ||
sizeClasses[size], | ||
variantClasses[variant] | ||
); | ||
|
||
return <button className={buttonClass} {...rest} />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { Button as default } from './Button'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import clsx from 'clsx'; | ||
import { ReactNode } from 'react'; | ||
|
||
interface ICardProps { | ||
children: ReactNode; | ||
px?: 'px-0' | 'px-6'; | ||
pb?: 'pb-0' | 'pb-6'; | ||
title?: string; | ||
className?: string; | ||
} | ||
|
||
export function Card(props: ICardProps) { | ||
const { children, px = 'px-6', title, pb = 'pb-6', className } = props; | ||
|
||
const baseClasses = 'border-neutral-90 border pt-6 rounded-lg bg-white'; | ||
|
||
const pxClasses = clsx(baseClasses, px, pb, className); | ||
|
||
return ( | ||
<div className={pxClasses}> | ||
{title && <h3 className="font-semibold mb-2">{title}</h3>} | ||
<div className="text-sm">{children}</div> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { Card as default } from './Card'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import clsx from 'clsx'; | ||
|
||
interface IPillProps { | ||
/** | ||
* The type of pill. Determines background and border styles. | ||
* - `primary`: Primary-themed pill. | ||
* - `success`: Success-themed pill (default). | ||
*/ | ||
type?: 'success'; | ||
label: string; | ||
className?: string; | ||
} | ||
|
||
export function Pill(props: IPillProps) { | ||
const { label, type = 'success', className } = props; | ||
|
||
const baseClasses = 'rounded-[20px] inline-flex items-center justify-center'; | ||
|
||
const typeClasses = { | ||
success: 'bg-success-90 text-primary-20 px-4 py-1', | ||
}; | ||
|
||
const pillClass = clsx(baseClasses, typeClasses[type], className); | ||
|
||
return <div className={pillClass}>{label}</div>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { Pill as default } from './Pill'; |
40 changes: 40 additions & 0 deletions
40
libs/react/components/src/lib/PillContainer/PillContainer.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { useState } from 'react'; | ||
import Pill from '../Pill'; | ||
|
||
interface IPillContainerProps { | ||
data: string[]; | ||
type?: 'success'; | ||
maxVisible: number; | ||
} | ||
|
||
export function PillContainer({ | ||
data, | ||
type = 'success', | ||
maxVisible, | ||
}: IPillContainerProps) { | ||
const [showAll, setShowAll] = useState(false); | ||
const servicesToDisplay = showAll ? data : data.slice(0, maxVisible); | ||
|
||
return ( | ||
<div className="flex flex-col"> | ||
<div className="flex flex-wrap gap-1"> | ||
{servicesToDisplay.map((item, idx) => ( | ||
<Pill type={type} label={item} key={idx} /> | ||
))} | ||
</div> | ||
|
||
{data.length > maxVisible && ( | ||
<button | ||
className="mt-3 ml-auto mr-auto" | ||
onClick={() => setShowAll(!showAll)} | ||
aria-label={showAll ? 'Show fewer items' : 'Show all items'} | ||
> | ||
<p className="text-xs font-semibold"> | ||
{showAll ? `View Less` : `View All (+${data.length - maxVisible})`} | ||
</p> | ||
{/* <ChevronLeftIcon className={clsx('chevron-icon', { rotated: showAll })} /> */} | ||
</button> | ||
)} | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { PillContainer as default } from './PillContainer'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export { default as Button } from './Button'; | ||
export { default as Card } from './Card'; | ||
export { default as Pill } from './Pill'; | ||
export { default as PillContainer } from './PillContainer'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"extends": "../../../tsconfig.base.json", | ||
"compilerOptions": { | ||
"jsx": "react-jsx", | ||
"esModuleInterop": true, | ||
"module": "commonjs", | ||
"forceConsistentCasingInFileNames": true, | ||
"strict": true, | ||
"noImplicitOverride": true, | ||
"noPropertyAccessFromIndexSignature": true, | ||
"noImplicitReturns": true, | ||
"noFallthroughCasesInSwitch": true | ||
}, | ||
"files": [], | ||
"include": [], | ||
"references": [ | ||
{ | ||
"path": "./tsconfig.lib.json" | ||
}, | ||
{ | ||
"path": "./tsconfig.spec.json" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"outDir": "../../../dist/out-tsc", | ||
"declaration": true, | ||
"types": ["node"] | ||
}, | ||
"include": ["src/**/*.ts"], | ||
"exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"outDir": "../../../dist/out-tsc", | ||
"module": "commonjs", | ||
"types": ["jest", "node"] | ||
}, | ||
"include": [ | ||
"jest.config.ts", | ||
"src/**/*.test.ts", | ||
"src/**/*.spec.ts", | ||
"src/**/*.d.ts" | ||
] | ||
} |
2 changes: 1 addition & 1 deletion
2
libs/react/shelter/src/lib/apollo/graphql/__generated__/types.ts
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
export default function Actions() { | ||
return ( | ||
<div className="flex items-center py-4 justify-between text-xs px-11 border-neutral-90 border-t border-b mt-4 -mx-4"> | ||
<div> | ||
<span>Call</span> | ||
</div> | ||
<div> | ||
<span>Directions</span> | ||
</div> | ||
<div> | ||
<span>Share</span> | ||
</div> | ||
</div> | ||
); | ||
} |
48 changes: 48 additions & 0 deletions
48
libs/react/shelter/src/lib/pages/shelter/EntryRequirements.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { Card } from '@monorepo/react/components'; | ||
import { enumDisplayEntryRequirementChoices } from '../../static'; | ||
import { ViewShelterQuery } from './__generated__/shelter.generated'; | ||
|
||
export default function EntryRequirements({ | ||
shelter, | ||
}: { | ||
shelter: ViewShelterQuery['shelter']; | ||
}) { | ||
return ( | ||
<Card title="Entry Requirements"> | ||
<div className="flex flex-col gap-2"> | ||
{shelter.entryRequirements.map((requirement, idx) => { | ||
if (!requirement.name) return null; | ||
return ( | ||
<div key={idx}> | ||
{enumDisplayEntryRequirementChoices[requirement.name]} | ||
</div> | ||
); | ||
})} | ||
{shelter.entryInfo && ( | ||
<div | ||
className="flex gap-1" | ||
dangerouslySetInnerHTML={{ | ||
__html: 'Entry Info: ' + shelter?.entryInfo, | ||
}} | ||
/> | ||
)} | ||
{shelter.bedFees && ( | ||
<div | ||
className="flex gap-1" | ||
dangerouslySetInnerHTML={{ | ||
__html: 'Bed Fees: ' + shelter?.bedFees, | ||
}} | ||
/> | ||
)} | ||
{shelter.programFees && ( | ||
<div | ||
className="flex gap-1" | ||
dangerouslySetInnerHTML={{ | ||
__html: 'Program Fees: ' + shelter?.programFees, | ||
}} | ||
/> | ||
)} | ||
</div> | ||
</Card> | ||
); | ||
} |
32 changes: 32 additions & 0 deletions
32
libs/react/shelter/src/lib/pages/shelter/GeneralInfo/GeneralServices.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { PillContainer } from '@monorepo/react/components'; | ||
import { enumDisplayGeneralServiceChoices } from '../../../static'; | ||
import { ViewShelterQuery } from '../__generated__/shelter.generated'; | ||
|
||
export default function GeneralServices({ | ||
shelter, | ||
}: { | ||
shelter: ViewShelterQuery['shelter']; | ||
}) { | ||
return ( | ||
<> | ||
<div> | ||
<p>Available General Services</p> | ||
</div> | ||
<div className="pb-6"> | ||
<PillContainer | ||
maxVisible={5} | ||
data={ | ||
shelter.generalServices?.reduce<string[]>((acc, service) => { | ||
if (service.name) { | ||
const displayName = | ||
enumDisplayGeneralServiceChoices[service.name]; | ||
if (displayName) acc.push(displayName); | ||
} | ||
return acc; | ||
}, []) || [] | ||
} | ||
/> | ||
</div> | ||
</> | ||
); | ||
} |
Oops, something went wrong.