-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- starting implementarion of the custom news feed
- implemented nav component
- Loading branch information
Showing
4 changed files
with
77 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { useState } from 'react' | ||
|
||
interface NavigatorProps { | ||
onChange: (valeu: string) => void | ||
options: string[] | ||
defaultValue?: string | ||
} | ||
|
||
export function Navigator({ | ||
onChange, | ||
options, | ||
defaultValue = '', | ||
}: NavigatorProps) { | ||
const [checked, setCheked] = useState(defaultValue) | ||
|
||
function renderButton(_options: string[]) { | ||
if (!_options || _options.length === 0) { | ||
return null | ||
} | ||
|
||
return _options.map((item) => { | ||
return ( | ||
<button | ||
onClick={() => { | ||
handleChangePage(item) | ||
}} | ||
key={item} | ||
data-ui={item === checked ? 'checked' : ''} | ||
className="relative flex h-full items-center justify-center px-3 data-checked:after:absolute data-checked:after:bottom-0 data-checked:after:h-0.5 data-checked:after:w-full data-checked:after:bg-slate-800" | ||
> | ||
{item} | ||
</button> | ||
) | ||
}) | ||
} | ||
|
||
function handleChangePage(value: string) { | ||
setCheked(value) | ||
onChange(value) | ||
} | ||
|
||
return ( | ||
<div className="flex h-10 w-full flex-row items-center border-b-half border-slate-400"> | ||
{renderButton(options)} | ||
</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,15 @@ | ||
import { Header } from '@/components/header' | ||
import Head from 'next/head' | ||
import { NewsFeedContainer } from './news-feed-container' | ||
|
||
export default function CustomNewsFeed() { | ||
return ( | ||
<> | ||
<Head> | ||
<title>feed | News Agreggator</title> | ||
</Head> | ||
<Header /> | ||
<NewsFeedContainer /> | ||
</> | ||
) | ||
} |
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,9 @@ | ||
import { Navigator } from './components/navigator' | ||
const tabs = ['News Feed', 'Preferences'] | ||
export function NewsFeedContainer() { | ||
return ( | ||
<section className="m-auto mt-16 flex w-full max-w-feed flex-col items-center justify-center px-6 pb-6"> | ||
<Navigator options={tabs} onChange={() => {}} defaultValue={tabs[0]} /> | ||
</section> | ||
) | ||
} |
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