Skip to content

Commit

Permalink
2 column layout
Browse files Browse the repository at this point in the history
  • Loading branch information
piggydoughnut committed Mar 3, 2024
1 parent 0d9a507 commit 5fb00d7
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 85 deletions.
35 changes: 12 additions & 23 deletions config-demo/application.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,11 @@
},
"layout": {
"mobile": {
"fixed": [
["users", "NewjoinerDetector"],
["users", "UserStatus"]
],
"fixed": [["users", "NewjoinerDetector"]],
"office": [
["office-visits", "Actions", { "offices": ["berlin"] }],
["announcements", "Announcement"],
["checklists", "Checklist"],
["working-hours", "WorkingHoursWidget"],
["events", "UncompletedActions"],
["events", "MyEvents"],
["office-visits", "MyOfficeVisits", { "offices": ["berlin"] }],
["visits", "WhoIsInOffice", { "offices": ["berlin"] }],
["quick-navigation", "QuickNav"],
["users", "UsersMapWidget"],
["events", "GlobalEvents", { "offices": ["global"] }]
Expand All @@ -32,21 +24,18 @@
["quick-navigation", "QuickNav"]
],
[
["users", "UserStatus"],
["office-visits", "Actions", { "offices": ["berlin"] }],
[
"office-visits",
"Actions",
{ "offices": ["berlin", "lisbon", "london"] }
],
["announcements", "Announcement"],
["checklists", "Checklist"],
["events", "UncompletedActions"],
["office-visits", "MyOfficeVisits", { "offices": ["berlin"] }],
["visits", "WhoIsInOffice", { "offices": ["berlin"] }],
["users", "UsersMapWidget"],
["events", "GlobalEvents", { "offices": ["global"] }]
],
[
["working-hours", "WorkingHoursWidget"],
["events", "MyEvents"],
["events", "UpcomingEvents"],
["news", "LatestNews"]
["users", "UsersMapWidget", { "offices": ["global"] }],
["events", "GlobalEvents", { "offices": ["global"] }],
[
["events", "UpcomingEvents"],
["news", "LatestNews"]
]
]
]
}
Expand Down
1 change: 0 additions & 1 deletion src/client/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { api } from '#client/utils/api'
import { getComponentInstance } from '#client/utils/portal'
import { PermissionsSet } from '#shared/utils'
import { PolkadotProvider } from '#client/components/auth/PolkadotProvider'
import { Welcome } from '#modules/users/client/components'

const routeGroups: Record<
'admin' | 'public' | 'extra' | 'extraLayout',
Expand Down
27 changes: 15 additions & 12 deletions src/client/components/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,31 +52,34 @@ export const Home: React.FC = () => {
className={cn(
'grid',
layoutView === 'mobile' && 'grid-cols-[minmax(0,_1fr)]',
layoutView === 'tablet' &&
'grid-cols-[minmax(0,_1fr)_minmax(0,_1fr)]',
layoutView === 'tablet' && 'grid-cols-[minmax(0,_1fr)]',
layoutView === 'desktop' &&
'grid-cols-[minmax(0,_25fr)_minmax(0,_44fr)_minmax(0,_31fr)]',
'grid-cols-[minmax(0,_25fr)_minmax(0,_75fr)]',
'gap-x-4'
)}
>
{/* mobile columns */}
{layoutView === 'mobile' && (
<div>{config.layout.mobile[tab].map(renderWidget)}</div>
)}

{/* desktop first column */}
{layoutView === 'desktop' && (
<div>{config.layout.desktop[0].map(renderWidget)}</div>
<div>{config.layout.desktop.sidebar.map(renderWidget)}</div>
)}

{/* desktop second column === tablet first column */}
{(layoutView === 'desktop' || layoutView === 'tablet') && (
<div>{config.layout.desktop[1].map(renderWidget)}</div>
)}

{/* desktop third column === tablet second column */}
{(layoutView === 'desktop' || layoutView === 'tablet') && (
<div>{config.layout.desktop[2].map(renderWidget)}</div>
<div>
{config.layout.desktop.main.map((row) => (
<div
className={cn(
'grid items-stretch',
row.length == 2 ? 'grid grid-cols-2 gap-2' : 'grid-cols-1'
)}
>
{row.map(renderWidget)}
</div>
))}
</div>
)}
</div>
</>
Expand Down
82 changes: 44 additions & 38 deletions src/client/components/auth/PolkadotProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { useCallback, useEffect, useMemo, useState } from 'react'
import {
BackButton,
FButton,
Icons,
Input,
Expand Down Expand Up @@ -204,47 +205,52 @@ export const PolkadotProvider: React.FC = () => {
)
case AuthSteps.ChooseAccount:
return (
<StepWrapper
title="Choose your account"
subtitle={`Works with Polkadot Js and Talisman`}
>
<div className="grid grid-cols-[1fr_2fr_1fr]">
<div>
<Select
placeholder="select account"
containerClassName="w-full mt-8 mb-4"
value={selectedAddress}
onChange={(v) => {
setSelectedAddress(v)
setError('')
}}
options={[{ label: 'select account', value: '' }].concat(
accounts.map((account) => ({
label: `${account.meta.name} (${account.meta.source})`,
value: account.address,
}))
)}
></Select>
<div className="flex align-middle justify-center gap-2 mb-14">
<Icons.WarningIcon />
<P
textType="additional"
className="text-text-secondary mt-0 max-w-[400px] text-left"
>
We strongly recommend to use a separate empty account as
identity instead of your wallet with real funds.
</P>
</div>
<BackButton className="self-start" />
</div>
<FButton
className="w-full"
kind="primary"
size="small"
onClick={() => handleLogin()}
<StepWrapper
title="Choose your account"
subtitle={`Works with Polkadot Js and Talisman`}
>
Continue
</FButton>
{error && <div className="text-accents-red">{error}</div>}
</StepWrapper>
<div>
<Select
placeholder="select account"
containerClassName="w-full mt-4 mb-2"
value={selectedAddress}
onChange={(v) => {
setSelectedAddress(v)
setError('')
}}
options={[{ label: 'select account', value: '' }].concat(
accounts.map((account) => ({
label: `${account.meta.name} (${account.meta.source})`,
value: account.address,
}))
)}
></Select>
<div className="flex align-middle justify-center gap-2 mb-14">
<Icons.WarningIcon />
<P
textType="additional"
className="text-text-secondary mt-0 max-w-[400px] text-left"
>
We strongly recommend to use a separate empty account as
identity instead of your wallet with real funds.
</P>
</div>
</div>
<FButton
className="w-full"
kind="primary"
size="small"
onClick={() => handleLogin()}
>
Continue
</FButton>
{error && <div className="text-accents-red">{error}</div>}
</StepWrapper>
</div>
)
case AuthSteps.Warning:
return (
Expand Down
23 changes: 12 additions & 11 deletions src/server/app-config/schemas.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import { z } from 'zod'
import { any, z } from 'zod'

export const componentRef = z
.tuple([z.string(), z.string()])
.or(
const componentRef: z.ZodTypeAny = z.lazy(() =>
z.union([
z.tuple([z.string(), z.string()]),
z.tuple([
z.string(),
z.string(),
z.object({ offices: z.array(z.string()).optional() }),
])
)
]),
z.array(componentRef),
])
)

export const layout = z.object({
mobile: z.object({
Expand All @@ -17,11 +19,10 @@ export const layout = z.object({
events: z.array(componentRef),
news: z.array(componentRef),
}),
desktop: z.tuple([
z.array(componentRef),
z.array(componentRef),
z.array(componentRef),
]),
desktop: z.object({
sidebar: z.array(componentRef),
main: z.array(z.array(componentRef)),
}),
})

export const applicationConfig = z.object({
Expand Down

0 comments on commit 5fb00d7

Please sign in to comment.