tangled
alpha
login
or
join now
leaflet.pub
/
leaflet
297
fork
atom
a tool for shared writing and social publishing
297
fork
atom
overview
issues
31
pulls
pipelines
scrolling save button on settings
cozylittle.house
1 week ago
5baab1bb
9db783c4
+46
-6
1 changed file
expand all
collapse all
unified
split
app
lish
[did]
[publication]
dashboard
settings
SettingsContent.tsx
+46
-6
app/lish/[did]/[publication]/dashboard/settings/SettingsContent.tsx
reviewed
···
164
164
<DashboardContainer className="bg-[rgb(var(--accent-light))]">
165
165
{canSeePro && !isPro ? <InlineUpgrade /> : <ManageProSubscription />}
166
166
</DashboardContainer>
167
167
-
<div className="bg-[rgb(var(--accent-1))] text-accent-2 text-sm rounded-md sticky bottom-2 mx-2 border-border-light pr-1 pl-2 flex justify-between items-center py-1 ">
168
168
-
You have unsaved updates!
169
169
-
<ButtonSecondary type="submit" disabled={loading}>
170
170
-
{loading ? <DotLoader /> : "Update Pub"}
171
171
-
</ButtonSecondary>
172
172
-
</div>
167
167
+
168
168
+
<SettingsFooter loading={loading} />
173
169
</div>
174
170
</form>
171
171
+
);
172
172
+
}
173
173
+
174
174
+
function SettingsFooter(props: { loading: boolean }) {
175
175
+
let [distanceFromBottom, setDistanceFromBottom] = useState<number>(Infinity);
176
176
+
177
177
+
useEffect(() => {
178
178
+
const scrollContainer = document.getElementById("home-content");
179
179
+
if (!scrollContainer) return;
180
180
+
181
181
+
const handleScroll = () => {
182
182
+
const dist =
183
183
+
scrollContainer.scrollHeight -
184
184
+
scrollContainer.scrollTop -
185
185
+
scrollContainer.clientHeight;
186
186
+
setDistanceFromBottom(dist);
187
187
+
};
188
188
+
189
189
+
handleScroll();
190
190
+
scrollContainer.addEventListener("scroll", handleScroll);
191
191
+
return () => scrollContainer.removeEventListener("scroll", handleScroll);
192
192
+
}, []);
193
193
+
194
194
+
const threshold = 100;
195
195
+
// ratio: 1 = far from bottom (full margin), 0 = at bottom (no margin)
196
196
+
const ratio = Math.min(distanceFromBottom / threshold, 1);
197
197
+
const mx = ratio * 8; // 8px = mx-2
198
198
+
199
199
+
return (
200
200
+
<div
201
201
+
className="settingsFooter sticky bottom-0 z-10"
202
202
+
style={{
203
203
+
paddingLeft: `${mx}px`,
204
204
+
paddingRight: `${mx}px`,
205
205
+
paddingBottom: `${mx}px`,
206
206
+
}}
207
207
+
>
208
208
+
<div className="bg-[rgb(var(--accent-1))] text-accent-2 text-sm rounded-md border-border-light pr-1 pl-2 flex justify-between items-center py-1">
209
209
+
You have unsaved updates!
210
210
+
<ButtonSecondary type="submit" disabled={props.loading}>
211
211
+
{props.loading ? <DotLoader /> : "Update Pub"}
212
212
+
</ButtonSecondary>
213
213
+
</div>
214
214
+
</div>
175
215
);
176
216
}
177
217