Skip to content

Commit

Permalink
feat: multiline alt text (#1765)
Browse files Browse the repository at this point in the history
  • Loading branch information
aeharding authored Dec 4, 2024
1 parent 0857625 commit ad3e89a
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 6 deletions.
5 changes: 5 additions & 0 deletions src/core/globalCssOverrides.css
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ ion-alert.preserve-newlines {
display: none;
}

.pswp__hide-on-close {
/* Photoswipe `will-change: opacity` breaks alt text backdrop-filter (when opened) */
will-change: auto !important;
}

ion-action-sheet .detail::before {
content: "";
z-index: 1;
Expand Down
10 changes: 10 additions & 0 deletions src/features/media/gallery/actions/AltText.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
max-width: 600px;
width: 100%;

margin-top: calc(
var(--ion-safe-area-top, env(safe-area-inset-top, 0)) + 50px
);

overflow-y: auto;

display: flex;
flex-direction: column;
align-items: center;
Expand Down Expand Up @@ -46,6 +52,8 @@
line-height: 1.2;

position: relative;

white-space: pre-wrap;
}

.clamped {
Expand All @@ -57,4 +65,6 @@
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
overflow: hidden;

white-space: initial;
}
2 changes: 1 addition & 1 deletion src/features/media/gallery/actions/AltText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default function AltText({ alt }: AltTextProps) {
if (!alt) return;

return (
<div className={styles.container}>
<div className={cx("alt-text", styles.container)}>
<div
className={styles.text}
onClick={() => setShouldClampAltText((v) => !v)}
Expand Down
2 changes: 1 addition & 1 deletion src/features/media/gallery/actions/ImageMoreActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default function ImageMoreActions({
{alt && (
<BottomContainer>
<AltText alt={alt} />
<BottomContainerActions withBg={false} />
<BottomContainerActions withBg={!!alt} />
</BottomContainer>
)}
</>
Expand Down
24 changes: 21 additions & 3 deletions src/features/media/gallery/actions/shared.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,22 @@
right: 0;
left: 0;

max-height: 100%;

display: flex;
flex-direction: column;
align-items: center;

--topPadding: 4rem;
> *:not(.bottomContainerActions) {
position: relative;
z-index: 1;
}
}

.bottomContainerActions {
width: 100%;

padding: 1rem;
padding-top: var(--topPadding);
padding-bottom: calc(
1rem + var(--ion-safe-area-bottom, env(safe-area-inset-bottom, 0))
);
Expand All @@ -30,5 +34,19 @@
}

.withBg {
background: linear-gradient(0deg, rgba(0, 0, 0, 1), transparent);
&:after {
content: "";
position: absolute;
bottom: 0;
left: 0;
right: 0;
height: 100%;

background: linear-gradient(0deg, rgba(0, 0, 0, 1), transparent);
}

> * {
position: relative;
z-index: 1;
}
}
4 changes: 3 additions & 1 deletion src/features/post/new/PostEditorRoot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -339,9 +339,11 @@ export default function PostEditorRoot({
message: "Add an accessible caption",
inputs: [
{
type: "textarea",
value: altText,
placeholder: "Fluffy fur blankets the feline...",
placeholder: "Fluffy fur blankets the feline",
name: "altText",
attributes: { rows: 3 },
},
],
buttons: [
Expand Down

0 comments on commit ad3e89a

Please sign in to comment.