Skip to content

Commit bdbaa4e

Browse files
committed
feat: continued with pad link functionality
1 parent d46286c commit bdbaa4e

5 files changed

Lines changed: 113 additions & 11 deletions

File tree

src/static/js/scroll.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ class Scroll {
1616
this.outerWin = outerWin;
1717
this.doc = this.outerWin.contentDocument!;
1818
this.rootDocument = document;
19-
console.log(this.rootDocument)
2019
}
2120

2221
scrollWhenCaretIsInTheLastLineOfViewportWhenNecessary(rep: RepModel, isScrollableEvent: boolean, innerHeight: number) {

src/static/skins/colibris/index.css

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,16 +167,44 @@ body nav {
167167
max-width: 56rem;
168168
}
169169

170+
.break-column {
171+
flex-basis: 100%;
172+
width: 0;
173+
}
174+
170175
ul {
171176
list-style-type: none;
172177
}
173178

179+
.recent-pad {
180+
padding: 0.75rem 1.5rem;
181+
display: flex;
182+
position: relative;
183+
flex-direction: column;
184+
}
185+
186+
.recent-pad:hover a {
187+
color: var(--ep-color);
188+
}
189+
190+
.recent-pad-arrow {
191+
position: absolute;
192+
right: 1rem;
193+
}
194+
195+
.recent-pad a {
196+
font-size: 0.875rem;
197+
line-height: 1.25rem;
198+
font-weight: 800;
199+
}
200+
201+
a, a:visited, a:hover, a:active {
202+
color: inherit;
203+
}
204+
174205
.pad-datalist h2 {
175206
border-bottom: 1px solid var(--muted-border);
176-
padding-left: 1.5rem;
177-
padding-right: 1.5rem;
178-
padding-top: 1rem;
179-
padding-bottom: 1rem;
207+
padding: 1rem 1.5rem;
180208
border-bottom-width: 1px;
181209
border-bottom-style: solid;
182210
border-bottom-color: #e5e7eb;

src/static/skins/colibris/index.js

Lines changed: 67 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ window.customStart = () => {
1919
parentStyle.display = 'flex';
2020
parentStyle.justifyContent = 'center';
2121
parentStyle.alignItems = 'center';
22-
parentStyle.height = '100%';
22+
parentStyle.maxHeight = '100%';
2323
recentPadList.remove();
2424
} else {
2525
/**
@@ -30,15 +30,79 @@ window.customStart = () => {
3030
/**
3131
* @param {Pad} pad
3232
*/
33+
34+
const arrowIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-arrow-right w-4 h-4 text-gray-400"><path d="M5 12h14"></path><path d="m12 5 7 7-7 7"></path></svg>';
35+
const clockIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-clock w-3 h-3"><circle cx="12" cy="12" r="10"></circle><polyline points="12 6 12 12 16 14"></polyline></svg>';
36+
const personalIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-users w-3 h-3"><path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"></path><circle cx="9" cy="7" r="4"></circle><path d="M22 21v-2a4 4 0 0 0-3-3.87"></path><path d="M16 3.13a4 4 0 0 1 0 7.75"></path></svg>';
3337
recentPadListData.forEach((pad) => {
3438
const li = document.createElement('li');
39+
40+
41+
li.style.cursor = 'pointer';
42+
3543
li.className = 'recent-pad';
3644
const padPath = `${window.location.href}p/${pad.name}`;
3745
const link = document.createElement('a');
46+
link.style.textDecoration = 'none';
47+
3848
link.href = padPath;
39-
link.innerText = pad;
49+
link.innerText = pad.name;
4050
li.appendChild(link);
41-
//https://v0.dev/chat/etherpad-design-clone-qZnwOrVRXxH
51+
52+
53+
const arrowIconElement = document.createElement('span');
54+
arrowIconElement.className = 'recent-pad-arrow';
55+
arrowIconElement.innerHTML = arrowIcon;
56+
li.appendChild(arrowIconElement);
57+
58+
const nextRow = document.createElement('div');
59+
60+
nextRow.style.display = 'flex';
61+
nextRow.style.gap = '10px';
62+
nextRow.style.marginTop = '10px';
63+
64+
const clockIconElement = document.createElement('span');
65+
clockIconElement.className = 'recent-pad-clock';
66+
clockIconElement.innerHTML = clockIcon;
67+
68+
nextRow.appendChild(clockIconElement);
69+
70+
const time = new Date(pad.timestamp);
71+
const userLocale = navigator.language || 'en-US';
72+
73+
const formattedTime = time.toLocaleDateString(userLocale, {
74+
year: 'numeric',
75+
month: '2-digit',
76+
day: '2-digit',
77+
hour: '2-digit',
78+
minute: '2-digit',
79+
});
80+
const timeElement = document.createElement('span');
81+
timeElement.className = 'recent-pad-time';
82+
timeElement.innerText = formattedTime;
83+
84+
nextRow.appendChild(timeElement);
85+
86+
const personalIconElement = document.createElement('span');
87+
personalIconElement.className = 'recent-pad-personal';
88+
personalIconElement.innerHTML = personalIcon;
89+
90+
personalIconElement.style.marginLeft = '5px';
91+
92+
const members = document.createElement('span');
93+
members.className = 'recent-pad-members';
94+
members.innerText = pad.members;
95+
96+
97+
nextRow.appendChild(personalIconElement);
98+
nextRow.appendChild(members);
99+
li.appendChild(nextRow);
100+
101+
li.addEventListener('click', () => {
102+
window.location.href = padPath;
103+
});
104+
105+
// https://v0.dev/chat/etherpad-design-clone-qZnwOrVRXxH
42106
recentPadList.appendChild(li);
43107
});
44108
}

src/static/skins/colibris/pad.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,22 @@ window.customStart = () => {
1212
localStorage.setItem('recentPads', JSON.stringify([]));
1313
}
1414
const recentPadsList = JSON.parse(localStorage.getItem('recentPads'));
15-
if (!recentPadsList.includes(padName)) {
15+
if (!recentPadsList.some((pad) => pad.name === padName)) {
1616
if (recentPadsList.length >= 10) {
1717
recentPadsList.shift(); // Remove the oldest pad if we have more than 10
1818
}
19-
recentPadsList.push(padName);
19+
recentPadsList.push({
20+
name: padName,
21+
timestamp: new Date().toISOString(), // Store the timestamp for sorting
22+
members: 0,
23+
});
24+
localStorage.setItem('recentPads', JSON.stringify(recentPadsList));
25+
} else {
26+
// Update the timestamp if the pad already exists
27+
const existingPad = recentPadsList.find((pad) => pad.name === padName);
28+
if (existingPad) {
29+
existingPad.timestamp = new Date().toISOString();
30+
}
2031
localStorage.setItem('recentPads', JSON.stringify(recentPadsList));
2132
}
2233
};

src/templates/pad.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ <h2 data-l10n-id="pad.settings.myView"></h2>
164164
</p>
165165
<% e.end_block(); %>
166166
</div>
167-
<button data-l10n-id="pad.settings.delete" id="delete-pad">Delete pad</button>
167+
<button data-l10n-id="pad.settings.deletePad" id="delete-pad">Delete pad</button>
168168
<h2 data-l10n-id="pad.settings.about">About</h2>
169169
<span data-l10n-id="pad.settings.poweredBy">Powered by</span>
170170
<a href="https://etherpad.org" target="_blank" referrerpolicy="no-referrer" rel="noopener">Etherpad</a>

0 commit comments

Comments
 (0)