Skip to content

Commit ceb3e3c

Browse files
committed
Update admin layout on mobile
1 parent cc667a4 commit ceb3e3c

File tree

4 files changed

+56
-24
lines changed

4 files changed

+56
-24
lines changed

src/client/components/AdminHome.tsx

Lines changed: 54 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,7 @@ import {
77
ADMIN_ACCESS_PERMISSION_RE,
88
ADMIN_ACCESS_PERMISSION_POSTFIX,
99
} from '#client/constants'
10-
import {
11-
Button,
12-
ComponentWrapper,
13-
WidgetWrapper,
14-
} from '#client/components/ui'
10+
import { WidgetWrapper } from '#client/components/ui'
1511
import Permissions from '#shared/permissions'
1612
import { PermissionsSet } from '#shared/utils'
1713
import { cn } from '#client/utils'
@@ -60,6 +56,7 @@ const _AdminHome: React.FC<Props> = ({ children }) => {
6056
const permissions = useStore(stores.permissions)
6157
const page = useStore(stores.router)
6258
const officeId = useStore(stores.officeId)
59+
const layoutView = useStore(stores.layoutView)
6360

6461
const filteredModules = React.useMemo(() => {
6562
return modulesWithAdminComponents.filter((m) => {
@@ -76,30 +73,65 @@ const _AdminHome: React.FC<Props> = ({ children }) => {
7673
})
7774
}, [permissions, officeId])
7875

79-
return filteredModules.length ? (
80-
<div className="grid grid-cols-[240px_minmax(0,auto)] gap-x-4">
81-
<div>
82-
<WidgetWrapper className="p-2 sticky top-2">
76+
if (!filteredModules.length) {
77+
return (
78+
<WidgetWrapper>
79+
Please select an office that you can work with.
80+
</WidgetWrapper>
81+
)
82+
}
83+
84+
if (layoutView === 'desktop') {
85+
return (
86+
<div className="grid grid-cols-[240px_minmax(0,auto)] gap-x-4">
87+
<div>
88+
<WidgetWrapper className="p-2 sticky top-2 -mb-1">
89+
{filteredModules.map((x, i) => {
90+
const isActive = !!(page && x.routes.includes(page.route))
91+
return (
92+
<ModuleLink
93+
key={x.id}
94+
isActive={isActive}
95+
module={x}
96+
className="mb-1"
97+
/>
98+
)
99+
})}
100+
</WidgetWrapper>
101+
</div>
102+
<div>
103+
<div>{children}</div>
104+
</div>
105+
</div>
106+
)
107+
}
108+
109+
return (
110+
<div>
111+
<WidgetWrapper className="p-2 ">
112+
<div className="flex flex-wrap -mb-1 -mr-1">
83113
{filteredModules.map((x, i) => {
84114
const isActive = !!(page && x.routes.includes(page.route))
85-
return <ModuleLink key={x.id} isActive={isActive} module={x} />
115+
return (
116+
<ModuleLink
117+
key={x.id}
118+
isActive={isActive}
119+
module={x}
120+
className="mr-1 mb-1"
121+
/>
122+
)
86123
})}
87-
</WidgetWrapper>
88-
</div>
89-
<div>
90-
<div>{children}</div>
91-
</div>
124+
</div>
125+
</WidgetWrapper>
126+
<div>{children}</div>
92127
</div>
93-
) : (
94-
<WidgetWrapper>
95-
Please select an office that you can work with.
96-
</WidgetWrapper>
97128
)
98129
}
99130

100131
const ModuleLink: React.FC<{
101132
isActive: boolean
102133
module: ModuleWithAdminComponents
134+
className?: string
103135
}> = (props) => {
104136
const officeId = useStore(stores.officeId)
105137
const counterApiUri = `/admin-api/${props.module.id}/counter`
@@ -115,9 +147,10 @@ const ModuleLink: React.FC<{
115147
<a
116148
href={`/admin/${props.module.id}`}
117149
className={cn(
118-
'relative flex items-center px-4 py-4 rounded-tiny hover:bg-gray-50',
150+
'relative flex items-center px-4 py-3 rounded-tiny hover:bg-gray-50',
119151
props.isActive &&
120-
'bg-purple-50 hover:bg-purple-50 bg-opacity-40 hover:bg-opacity-40 text-purple-500'
152+
'bg-purple-50 hover:bg-purple-50 bg-opacity-40 hover:bg-opacity-40 text-purple-500',
153+
props.className
121154
)}
122155
>
123156
<span className="flex-1 text-ellipsis overflow-hidden mr-1 whitespace-nowrap">

src/client/components/charts/StackedBarChart.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export const StackedBarChart = <X extends string, Y extends string>(
6161
if (!d3 || !container) return
6262
d3.select(ref.current).select('svg').remove()
6363

64-
const margin = { top: 4, right: 14, bottom: 14, left: 24 }
64+
const margin = { top: 4, right: 0, bottom: 14, left: 16 }
6565
const width = ref.current.clientWidth - margin.left - margin.right
6666
const height = (props.height || DEFAULT_HEIGHT) - margin.top - margin.bottom
6767
const barPadding = 2

src/modules/admin-dashboard/client/components/AdminDashboard.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ export const AdminDashboard: React.FC<RootComponentProps> = (props) => {
2020
}, [offset, unit])
2121

2222
const portalGroups = React.useMemo(() => {
23-
console.log('AdminDashboard', props.portals)
2423
const result = []
2524
for (const portalId in props.portals) {
2625
result.push({

src/modules/events/client/components/AdminEvents.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ export const AdminEvents = () => {
177177
accessor: (event: EventAdminResponse) => (
178178
<span className="inline-block -mr-1">
179179
{event.allowedRoles.map((x) => (
180-
<UserRoleLabel role={x} className="mr-1" />
180+
<UserRoleLabel key={x} role={x} className="mr-1" />
181181
))}
182182
</span>
183183
),

0 commit comments

Comments
 (0)