Sticly footer to the bottom of the page

This commit is contained in:
Daniel Weissmall 2022-10-14 15:03:37 +03:00
parent 49d15e538b
commit dcda165488
7 changed files with 51 additions and 19 deletions

View File

@ -12,6 +12,7 @@ import {
} from "components/icons"; } from "components/icons";
import classNames from "classnames"; import classNames from "classnames";
import { Transition } from "@headlessui/react"; import { Transition } from "@headlessui/react";
import Link from "components/typography/Link";
const interactionButtonsStore = [ const interactionButtonsStore = [
{ {
@ -46,6 +47,7 @@ type ArticleButtonProps = {
children?: React.ReactNode; children?: React.ReactNode;
className?: string; className?: string;
emphasis?: "high" | "low"; emphasis?: "high" | "low";
articleID?: string,
} & Omit<React.ComponentPropsWithoutRef<"button">, "">; } & Omit<React.ComponentPropsWithoutRef<"button">, "">;
export function ArticleInteractionButtons({ export function ArticleInteractionButtons({
@ -53,6 +55,7 @@ export function ArticleInteractionButtons({
children, children,
openAbstract = () => { }, openAbstract = () => { },
className, className,
articleID,
emphasis = "high", //to change displaying of component emphasis = "high", //to change displaying of component
...props ...props
}: ArticleButtonProps) { }: ArticleButtonProps) {
@ -70,18 +73,31 @@ export function ArticleInteractionButtons({
</Button.Icon> </Button.Icon>
</Button> </Button>
); );
const fileInteractionButtons = interactionButtonsStore.map((button) => { const fileInteractionButtons = interactionButtonsStore.map((button) => {
return ( return (
<Button button.title === 'Read file' ?
emphasis={button.buttonEmphasis === "high" ? "high" : "low"} <Link
className="h-max px-2 mr-2" to={`/article/content/${articleID}`}>
> <Button
<Button.Icon> emphasis={button.buttonEmphasis === "high" ? "high" : "low"}
{React.cloneElement(button.icon, { className: button.iconClassName })} className="h-max px-2 mr-2"
</Button.Icon> >
{emphasis === "high" ? <Typography>{button.title}</Typography> : null} <Button.Icon>
</Button> {React.cloneElement(button.icon, { className: button.iconClassName })}
</Button.Icon>
{emphasis === "high" ? <Typography>{button.title}</Typography> : null}
</Button>
</Link>
:
<Button
emphasis={button.buttonEmphasis === "high" ? "high" : "low"}
className="h-max px-2 mr-2"
>
<Button.Icon>
{React.cloneElement(button.icon, { className: button.iconClassName })}
</Button.Icon>
{emphasis === "high" ? <Typography>{button.title}</Typography> : null}
</Button>
); );
}); });

View File

@ -37,7 +37,7 @@ export const ArticleSearchResult = ({ searchItem }: Props) => {
<Article.SubscriptionsButtons /> <Article.SubscriptionsButtons />
</div> </div>
<Article.Title linkTo={`/article/${searchItem.id}`} className="text-2xl"> <Article.Title linkTo={`/article/info/${searchItem.id}`} className="text-2xl">
{searchItem.title} {searchItem.title}
</Article.Title> </Article.Title>
<Article.Authors emphasis="low" className="flex flex-wrap flex-row"> <Article.Authors emphasis="low" className="flex flex-wrap flex-row">

View File

@ -1,3 +1,4 @@
import { joinClassnames } from "core/helpers";
import React from "react"; import React from "react";
import { Footer } from "./parts/Footer"; import { Footer } from "./parts/Footer";
import Header from "./parts/Header"; import Header from "./parts/Header";
@ -10,10 +11,10 @@ type Props = {
function BaseLayout({ header, footer, children, className }: Props) { function BaseLayout({ header, footer, children, className }: Props) {
return ( return (
<div className={className}> <div className={joinClassnames(className, 'flex min-h-screen flex-col justify-between')}>
<Header /> <Header />
<main>{children}</main> <main className="flex-1">{children}</main>
<Footer /> <Footer />
</div> </div>

View File

@ -46,7 +46,10 @@ const AnArticle = () => {
<hr></hr> <hr></hr>
</div> </div>
<ArticlePart.Article.InteractionButtons emphasis="high" /> <ArticlePart.Article.InteractionButtons
emphasis="high"
articleID={article?.id}
/>
{article?.tags && ( {article?.tags && (
<div className="keywords my-10 flex flex-col gap-2"> <div className="keywords my-10 flex flex-col gap-2">
<Typography <Typography

View File

@ -8,10 +8,17 @@ export const handleScrollTo = (e: React.MouseEvent<HTMLAnchorElement>) => {
} }
}; };
export function capitalization (str: string) { export function capitalization(str: string): string {
return str.substring(0,1).toUpperCase() + str.substring(1); return str.substring(0, 1).toUpperCase() + str.substring(1);
} }
export function formatNumber(num: number) { export function formatNumber(num: number): string {
return num.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1 '); return num.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1 ');
}
export function joinClassnames(first?: string, second?: string): string {
return [
first ?? '',
second ?? '',
].join('');
} }

View File

@ -17,6 +17,8 @@ import { store } from "store/store";
import { Provider } from "react-redux"; import { Provider } from "react-redux";
import { SearchResultsPage } from "pages/SearchResultsPage"; import { SearchResultsPage } from "pages/SearchResultsPage";
import AnArticle from "components/fetchAnArticle/AnArticle"; import AnArticle from "components/fetchAnArticle/AnArticle";
import NotFound from "components/fetchAnArticle/NotFound";
import AnArticleBody from "components/fetchAnArticle/AnArticleBody";
const rootElement = document.getElementById("root"); const rootElement = document.getElementById("root");
if (!rootElement) throw new Error("Failed to find the root element"); if (!rootElement) throw new Error("Failed to find the root element");
@ -33,7 +35,10 @@ root.render(
<Route path="/terms-of-use" element={<TermsOfUse />} /> <Route path="/terms-of-use" element={<TermsOfUse />} />
<Route path="/privacy-policy" element={<PrivacyPolicy />} /> <Route path="/privacy-policy" element={<PrivacyPolicy />} />
<Route path="/cookies-policy" element={<CookiesPolicy />} /> <Route path="/cookies-policy" element={<CookiesPolicy />} />
<Route path="/article/:id" element={<AnArticle />} /> <Route path="/article">
<Route path="info/:id" element={<AnArticle />} />
<Route path="content/:id" element={<AnArticleBody />} />
</Route>
<Route path="/account"> <Route path="/account">
<Route path="settings" element={<AccountSettings />} /> <Route path="settings" element={<AccountSettings />} />
</Route> </Route>

View File

@ -13,7 +13,7 @@ export const SearchResultsPage = () => {
<SearchSection /> <SearchSection />
<ColumnLayout> <ColumnLayout>
<ColumnLayout.Left> <ColumnLayout.Left>
<div className="h-98 bg-blue-200 w-[300px]">left bar</div> <div className="h-98 w-[300px]"></div>
</ColumnLayout.Left> </ColumnLayout.Left>
<ColumnLayout.Main> <ColumnLayout.Main>
<SearchResultSection /> <SearchResultSection />