Skip to content

Commit

Permalink
feat: optimize height control for mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
zmh-program committed Mar 6, 2024
1 parent 1b5d9a1 commit e5a43ab
Show file tree
Hide file tree
Showing 12 changed files with 33 additions and 37 deletions.
3 changes: 1 addition & 2 deletions app/src/assets/admin/all.less
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
display: flex;
flex-direction: row;
width: 100%;
min-height: calc(100vh - 56px);
height: max-content;
height: calc(100% - 56px);
}

.admin-card {
Expand Down
2 changes: 1 addition & 1 deletion app/src/assets/admin/management.less
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
display: flex;
flex-direction: column;
width: 100%;
height: calc(100vh - 56px);
height: calc(100% - 56px);
padding: 2rem;

& > * {
Expand Down
4 changes: 2 additions & 2 deletions app/src/assets/admin/menu.less
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
margin: 0;
background: hsl(var(--background));
transition: 0.225s ease-in-out;
min-height: calc(100vh - 56px);
min-height: calc(100% - 56px);
transition-property: width, background, box-shadow, opacity;
border-right: 0;
opacity: 0;
Expand Down Expand Up @@ -77,7 +77,7 @@

.admin-content {
flex-grow: 1;
height: calc(100vh - 56px);
height: 100%;
overflow-x: hidden;
overflow-y: auto;
touch-action: pan-y;
Expand Down
2 changes: 1 addition & 1 deletion app/src/assets/common/404.less
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
flex-direction: column;
justify-content: center;
align-items: center;
height: calc(100vh - 56px);
height: calc(100% - 56px);
font-size: 30px;
color: hsl(var(--tw-content));
gap: 12px;
Expand Down
10 changes: 5 additions & 5 deletions app/src/assets/main.less
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
@-moz-osx-font-smoothing: grayscale;
@-webkit-text-size-adjust: 100%;

html, body {
html, body, #root {
margin: 0;
padding: 0;
width: 100%;
height: 100vh;
height: 100%;
overflow-x: hidden;
overflow-y: auto;
touch-action: pan-y;
Expand Down Expand Up @@ -139,9 +139,9 @@ strong {

@media (max-width: 660px) {
width: 100vw !important;
height: 100vh !important;
height: 100% !important;
max-width: 100vw !important;
max-height: 100vh !important;
max-height: 100% !important;
border-radius: 0 !important;
}
}
Expand All @@ -157,7 +157,7 @@ strong {
align-items: center;
width: 100%;
height: max-content;
min-height: calc(100vh - 56px);
min-height: calc(100% - 56px);
overflow: hidden;
background: hsla(var(--background-container));
padding: 2.5rem 5rem;
Expand Down
2 changes: 1 addition & 1 deletion app/src/assets/pages/article.less
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
position: relative;
display: flex;
width: 100%;
min-height: calc(100vh - 56px);
min-height: calc(100% - 56px);
height: max-content;
}

Expand Down
2 changes: 1 addition & 1 deletion app/src/assets/pages/auth.less
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.auth {
width: 100%;
height: calc(100vh - 56px);
height: calc(100% - 56px);
overflow: hidden;
background: hsla(var(--background-container));
}
Expand Down
1 change: 1 addition & 0 deletions app/src/assets/pages/chat.less
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@
border: 1px solid hsl(var(--border));
width: 2.5rem;
height: 2.5rem;
user-select: none;
}

&.user {
Expand Down
2 changes: 1 addition & 1 deletion app/src/assets/pages/generation.less
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
position: relative;
display: flex;
width: 100%;
height: calc(100vh - 56px);
height: calc(100% - 56px);

.login-action {
display: flex;
Expand Down
4 changes: 2 additions & 2 deletions app/src/assets/pages/home.less
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
display: flex;
flex-direction: row;
width: 100%;
height: calc(100vh - 56px);
height: calc(100% - 56px);
overflow: hidden;
}

Expand All @@ -13,7 +13,7 @@
width: 100%;
padding: 1rem 3.5rem;
height: max-content;
max-height: calc(100vh - 56px);
max-height: calc(100% - 56px);
overflow: auto;
scrollbar-width: thin;

Expand Down
25 changes: 9 additions & 16 deletions app/src/assets/pages/sharing.less
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,7 @@
position: relative;
display: flex;
width: 100%;
height: calc(100vh - 56px);
}

.loading {
margin: auto;
transform: translateY(-28px);
user-select: none;

.loader {
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}

animation: spin 1.25s cubic-bezier(0.5, 0, 0.5, 1) infinite;
}
height: calc(100% - 56px);
}

.error-container {
Expand Down Expand Up @@ -272,6 +257,14 @@
padding: 1rem;
scrollbar-width: thin;
gap: 8px;

.message {
margin-bottom: 8px;

&:last-child {
margin-bottom: 0;
}
}
}

.action {
Expand Down
13 changes: 8 additions & 5 deletions app/src/routes/Sharing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { appLogo } from "@/conf/env.ts";
import { extractMessage } from "@/utils/processor.ts";
import { cn } from "@/components/ui/lib/utils.ts";
import { useMobile } from "@/utils/device.ts";
import { ScrollArea } from "@/components/ui/scroll-area.tsx";

type SharingFormProps = {
refer?: string;
Expand Down Expand Up @@ -124,11 +125,11 @@ function SharingForm({ refer, data }: SharingFormProps) {
<div className={`name`}>{data.name}</div>
<div className={`time`}>{time}</div>
</div>
<div className={`body`}>
<ScrollArea className={`body`}>
{data.messages.map((message, i) => (
<MessageSegment message={message} key={i} index={i} />
))}
</div>
</ScrollArea>
<div className={`action`}>
<Button
variant={`outline`}
Expand Down Expand Up @@ -169,6 +170,8 @@ function Sharing() {
const [setup, setSetup] = useState(false);
const [data, setData] = useState<ViewForm | null>(null);

const loading = data === null;

useEffectAsync(async () => {
if (!hash || setup) return;

Expand All @@ -180,9 +183,9 @@ function Sharing() {
}, []);

return (
<div className={`sharing-page`}>
{data === null ? (
<div className={`loading`}>
<div className={cn(`sharing-page`, loading && "flex flex-row items-center justify-center")}>
{loading ? (
<div className={`animate-spin select-none`}>
<Loader2 className={`loader w-12 h-12`} />
</div>
) : data.status ? (
Expand Down

0 comments on commit e5a43ab

Please sign in to comment.