-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: change import alias * style: fix linting issues * chore: apply prettier * style: kebabe case file convention * chore: mify case ignorance * chore: fix import
- Loading branch information
Showing
28 changed files
with
511 additions
and
249 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
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
Large diffs are not rendered by default.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
interface IAlertProps { | ||
message: string; | ||
// type: string; | ||
} | ||
|
||
function Alert({ message }: IAlertProps) { | ||
return <section className="bg-green-200">{message}</section>; | ||
} | ||
|
||
export default Alert; |
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,61 @@ | ||
import { useEffect } from 'react'; | ||
import { Outlet, useLocation } from 'react-router-dom'; | ||
import { GrowthBook, GrowthBookProvider } from '@growthbook/growthbook-react'; | ||
|
||
import Header from '~/components/header'; | ||
import Alert from '~/components/alert'; | ||
import Breadcrumbs from '~/components/breadcrumbs'; | ||
|
||
// Create a GrowthBook instance | ||
const growthbook = new GrowthBook({ | ||
trackingCallback: (experiment, result) => { | ||
// eslint-disable-next-line no-console | ||
console.log({ | ||
experimentId: experiment.key, | ||
variationId: result.variationId, | ||
}); | ||
}, | ||
}); | ||
|
||
function App() { | ||
const location = useLocation(); | ||
|
||
useEffect(() => { | ||
// eslint-disable-next-line no-console | ||
console.log(`App version: ${APP_VERSION}`); | ||
|
||
// Load feature definitions from API | ||
fetch( | ||
`https://cdn.growthbook.io/api/features/${ | ||
import.meta.env.VITE_GROWTH_BOOK_KEY | ||
}`, | ||
) | ||
.then(async (res) => res.json()) | ||
.then((json) => { | ||
growthbook.setFeatures(json.features); | ||
}); | ||
|
||
// TODO: replace with real targeting attributes | ||
growthbook.setAttributes({ | ||
id: 'foo', | ||
deviceId: 'foo', | ||
company: 'foo', | ||
loggedIn: true, | ||
employee: true, | ||
country: 'foo', | ||
browser: 'foo', | ||
url: 'foo', | ||
}); | ||
}, [location]); | ||
|
||
return ( | ||
<GrowthBookProvider growthbook={growthbook}> | ||
<Header /> | ||
{location.pathname !== '/' && <Breadcrumbs />} | ||
<Alert message="" /> | ||
<Outlet /> | ||
</GrowthBookProvider> | ||
); | ||
} | ||
|
||
export default App; |
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,28 @@ | ||
import { useMatches } from 'react-router-dom'; | ||
|
||
import classes from './breadcrumbs.module.css'; | ||
|
||
function Breadcrumbs() { | ||
const matches = useMatches(); | ||
const crumbs = matches | ||
// first get rid of any matches that don't have handle and crumb | ||
.filter((match) => Boolean(match.handle?.crumb)) | ||
// now map them into an array of elements, passing the loader | ||
// data to each one | ||
.map((match) => match.handle.crumb(match.data)); | ||
|
||
return ( | ||
<div className="container mx-auto px-4"> | ||
<ol className={classes.breadcrumbs}> | ||
{crumbs.map((crumb, index) => ( | ||
// eslint-disable-next-line react/no-array-index-key | ||
<li className={classes.crumb} key={index}> | ||
{crumb} | ||
</li> | ||
))} | ||
</ol> | ||
</div> | ||
); | ||
} | ||
|
||
export default Breadcrumbs; |
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,51 @@ | ||
import { useEffect } from 'react'; | ||
import { Link } from 'react-router-dom'; | ||
import { themeChange } from 'theme-change'; | ||
|
||
function Header() { | ||
useEffect(() => { | ||
themeChange(false); | ||
// 👆 false parameter is required for react project | ||
}, []); | ||
|
||
return ( | ||
<nav className="navbar bg-neutral text-neutral-content mb-3"> | ||
<div className="flex-1"> | ||
<Link to="/" className="btn btn-ghost normal-case text-xl"> | ||
Microblogging | ||
</Link> | ||
</div> | ||
<div className="flex-none justify-between"> | ||
<button | ||
type="button" | ||
className="btn btn-circle mr-6" | ||
data-toggle-theme="forest,winter" | ||
data-act-class="ACTIVECLASS" | ||
aria-label="Dark Theme" | ||
> | ||
<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
fill="none" | ||
viewBox="0 0 24 24" | ||
strokeWidth={1.5} | ||
stroke="currentColor" | ||
className="w-6 h-6" | ||
> | ||
<path | ||
strokeLinecap="round" | ||
strokeLinejoin="round" | ||
d="M21.752 15.002A9.718 9.718 0 0118 15.75c-5.385 0-9.75-4.365-9.75-9.75 0-1.33.266-2.597.748-3.752A9.753 9.753 0 003 11.25C3 16.635 7.365 21 12.75 21a9.753 9.753 0 009.002-5.998z" | ||
/> | ||
</svg> | ||
</button> | ||
<form className="form-inline navbar-end"> | ||
<Link to="/posts/new" className="btn btn-outline btn-primary"> | ||
New Post | ||
</Link> | ||
</form> | ||
</div> | ||
</nav> | ||
); | ||
} | ||
|
||
export default Header; |
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,27 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
|
||
import { Input } from './input'; | ||
|
||
// More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction | ||
const meta = { | ||
title: 'Components/Input', | ||
component: Input, | ||
tags: ['autodocs'], | ||
argTypes: {}, | ||
} satisfies Meta<typeof Input>; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof meta>; | ||
|
||
// More on writing stories with args: https://storybook.js.org/docs/react/writing-stories/args | ||
export const Default: Story = { | ||
args: { | ||
size: 'large', | ||
}, | ||
}; | ||
|
||
export const Medium: Story = { | ||
args: { | ||
size: 'medium', | ||
}, | ||
}; |
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,47 @@ | ||
interface InputProps { | ||
/** | ||
* How large should the button be? | ||
*/ | ||
size?: 'medium' | 'large'; | ||
/** | ||
* What placeholder color to use | ||
*/ | ||
placeholder?: string; | ||
/** | ||
* Button contents | ||
*/ | ||
label?: string; | ||
/** | ||
* Input value | ||
*/ | ||
value?: string; | ||
/** | ||
* Optional change handler | ||
*/ | ||
onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void; | ||
} | ||
|
||
/** | ||
* Primary UI component for user interaction | ||
*/ | ||
export function Input({ | ||
size = 'large', | ||
placeholder, | ||
value, | ||
onChange, | ||
label, | ||
...props | ||
}: InputProps) { | ||
const sizeAdjusted = size === 'large' ? '3xl' : 'xl'; | ||
return ( | ||
<input | ||
type="text" | ||
placeholder={placeholder} | ||
value={value} | ||
onChange={onChange} | ||
className={['input', 'w-full', `text-${sizeAdjusted}`].join(' ')} | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
{...props} | ||
/> | ||
); | ||
} |
2 changes: 1 addition & 1 deletion
2
src/components/PostForm.stories.ts → src/components/post-form.stories.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
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
src/components/PostPreview.stories.ts → src/components/post-preview.stories.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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
function Search() { | ||
return ( | ||
<div className="col-span-12 w-full pb-6"> | ||
<input | ||
disabled | ||
type="search" | ||
className="disabled:bg-gray-100 rounded-l border border-blue-700 py-1 px-5" | ||
/> | ||
<button | ||
disabled | ||
type="button" | ||
className=" text-white fill rounded-r border bg-blue-700 border-blue-700 px-5 py-1" | ||
> | ||
Search | ||
</button> | ||
</div> | ||
); | ||
} | ||
|
||
export default Search; |
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
Oops, something went wrong.