Skip to content

Commit

Permalink
Fix template component scroll issues (#452)
Browse files Browse the repository at this point in the history
* fix(react): adjust template component style and fallback container

* fix(frontend): fix height styles when loading

* fix(frontend): fix height styles when loading on page component

* docs: add changeset

* fix(frontend): add missing h-screen styles
  • Loading branch information
guerrap authored Oct 23, 2023
1 parent e838ea3 commit 3f8af7b
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 12 deletions.
5 changes: 5 additions & 0 deletions .changeset/lazy-mangos-promise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@carrot-kpi/react": patch
---

Adjust template component style and fallback container styles
5 changes: 5 additions & 0 deletions .changeset/moody-days-brake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@carrot-kpi/host-frontend": patch
---

Fix height styles when loading on page and create component
14 changes: 7 additions & 7 deletions packages/frontend/src/pages/create-with-template-id/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const CreateWithTemplateId = () => {
const ipfsGatewayURL = useIPFSGatewayURL();
const invalidateLatestKPITokens = useInvalidateLatestKPITokens();

const [loading, setLoading] = useState(false);
const [loading, setLoading] = useState(true);
const [template, setTemplate] = useState<ResolvedTemplate | null>(
state && "specification" in state.template ? state.template : null,
);
Expand Down Expand Up @@ -126,30 +126,30 @@ export const CreateWithTemplateId = () => {

return (
<Layout navbarBgColor="green" noMarquee>
<div className="h-screen flex-grow bg-grid-light bg-left-top bg-green">
<div className="h-fit flex-grow bg-grid-light bg-left-top bg-green">
{loading || loadingPermission ? (
<div className="py-20 text-black flex justify-center">
<div className="h-screen py-20 text-black flex justify-center">
<Loader />
</div>
) : !creatorAllowed ? (
<div className="py-20">
<div className="h-screen py-20">
<Permissioned onBack={handleDismiss} />
</div>
) : !pinningProxyAuthenticated ? (
<div className="py-20">
<div className="h-screen py-20">
<Authenticate onCancel={handleDismiss} />
</div>
) : template ? (
<KPITokenCreationForm
key={formKey}
template={template || undefined}
fallback={
<div className="py-20 text-black flex justify-center">
<div className="h-screen py-20 text-black flex justify-center">
<Loader />
</div>
}
error={
<div className="py-20 flex justify-center">
<div className="h-screen py-20 flex justify-center">
<ErrorFeedback
messages={{
title: t(
Expand Down
6 changes: 3 additions & 3 deletions packages/frontend/src/pages/page/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@ export const Page = () => {

return (
<Layout navbarBgColor="orange">
<div className="flex-grow bg-grid-light bg-left-top bg-orange">
<div className="h-fit flex-grow bg-grid-light bg-left-top bg-orange">
<KPITokenPage
kpiToken={watchedKPITokenWithData}
i18n={i18n}
fallback={
<div className="text-black h-screen flex justify-center items-center">
<div className="h-screen py-20 text-black flex justify-center items-center">
<Loader />
</div>
}
error={
<div className="bg-grid-light h-screen flex justify-center items-center">
<div className="h-screen py-20 bg-grid-light flex justify-center items-center">
<ErrorFeedback
messages={{
title: t("error.initializing.page.title"),
Expand Down
5 changes: 3 additions & 2 deletions packages/react/src/components/template-component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { ErrorBoundary } from "./error-boundary";
import type { BaseTemplateComponentProps } from "../types/templates";
import { useNetwork } from "wagmi";

const wrapperStyles = cva(["w-full", "h-full"], {
const wrapperStyles = cva(["w-full", "h-fit"], {
variants: {
dark: {
true: ["dark"],
Expand Down Expand Up @@ -83,7 +83,8 @@ export function TemplateComponent({
);
}, [systemDarkTheme, theme]);

if (loading || !template || !Component) return <>{fallback}</>;
if (loading || !template || !Component)
return <div className="h-screen py-20">{fallback}</div>;
return (
<div
className={wrapperStyles({
Expand Down

0 comments on commit 3f8af7b

Please sign in to comment.