Skip to content

Commit

Permalink
feat: step 2
Browse files Browse the repository at this point in the history
  • Loading branch information
Henry-Wow committed Jan 19, 2025
1 parent bb1edbd commit 6f22ddf
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 40 deletions.
87 changes: 63 additions & 24 deletions src/lib/components/editors/CollaborativeEditor.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
flex-direction: row;
gap: 24px;
padding: 24px;
background-color: #f5f5f5;
height: 100vh;
min-height: 100vh;
}

.editors-container {
Expand All @@ -13,60 +12,79 @@
flex-direction: column;
gap: 24px;
max-height: calc(100vh - 48px);
margin: 0 auto;
width: 910px;
min-width: 910px;
transition: width 0.3s ease;
}

.container:has(.history-card) .editors-container {
width: 400px;
min-width: 400px;
}

.editor-card {
flex: 1;
display: flex;
flex-direction: column;
background-color: white;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
background-color: rgba(255, 255, 255, 0.1);
border-radius: 12px;
border: 1px solid rgba(255, 255, 255, 0.2);
backdrop-filter: blur(8px);
}

.editor-header {
padding: 16px;
border-bottom: 1px solid #eee;
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
display: flex;
justify-content: space-between;
align-items: center;
color: white;
}

.editor-title {
margin: 0;
color: #2c3e50;
color: white;
font-size: 18px;
}

.editor-content {
flex: 1;
padding: 16px;
overflow: auto;
color: rgba(255, 255, 255, 0.9);
}

.editor-content > :global(*) {
height: 100%;
}

.history-card {
width: 400px;
background-color: white;
border-radius: 8px;
width: 500px;
min-width: 500px;
background-color: rgba(255, 255, 255, 0.1);
border-radius: 12px;
padding: 20px;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
border: 1px solid rgba(255, 255, 255, 0.2);
backdrop-filter: blur(8px);
max-height: calc(100vh - 48px);
overflow: auto;
}

.history-title {
margin: 0 0 16px 0;
color: #2c3e50;
margin: 0;
color: white;
font-size: 18px;
position: sticky;
top: 0;
background-color: white;
padding: 8px 0;
background-color: rgba(255, 255, 255, 0.1);
padding: 12px 24px;
z-index: 1;
backdrop-filter: blur(8px);
border-radius: 24px;
text-align: center;
margin-bottom: 16px;
border: 1px solid rgba(255, 255, 255, 0.2);
}

.history-content {
Expand All @@ -78,23 +96,29 @@
.status-button {
color: white;
border: none;
padding: 8px 16px;
border-radius: 6px;
padding: 4px 8px;
border-radius: 4px;
cursor: pointer;
font-size: 14px;
transition: background-color 0.2s;
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
background-color: #4CAF50;
font-size: 12px;
transition: all 0.2s ease;
background-color: rgba(76, 29, 149, 0.5);
border: 1px solid rgba(255, 255, 255, 0.1);
backdrop-filter: blur(8px);
}

.status-button:hover {
background-color: #45a049;
background-color: rgba(139, 92, 246, 0.8);
border-color: rgba(255, 255, 255, 0.3);
transform: translateY(-1px);
}

.variant-filled.badge {
padding: 6px 12px;
font-size: 13px;
padding: 4px 8px;
font-size: 12px;
border-radius: 4px;
background-color: rgba(255, 255, 255, 0.1);
color: white;
border: 1px solid rgba(255, 255, 255, 0.2);
}

.dag-view-message {
Expand All @@ -104,6 +128,7 @@
align-items: center;
gap: 12px;
min-width: 0;
color: rgba(255, 255, 255, 0.9);
}

.dag-view-message > span {
Expand All @@ -115,4 +140,18 @@
.dag-view-message > span:first-child {
flex: 1;
min-width: 0;
}

@keyframes wiggle {
0% { transform: rotate(0deg); }
20% { transform: rotate(-10deg); }
40% { transform: rotate(10deg); }
60% { transform: rotate(-10deg); }
80% { transform: rotate(10deg); }
100% { transform: rotate(0deg); }
}

.too-long-content-badge {
animation: wiggle;
animation-duration: 1s;
}
2 changes: 1 addition & 1 deletion src/lib/components/editors/CompositeMarkdownEditor.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
{markdownMode ? 'Switch to Rich Text' : 'Switch to Markdown'}
</button>
<button class="status-button" onclick={toggleHistory}>
{showHistory ? '隐藏历史' : '显示历史'}
{showHistory ? 'Hide History' : 'Show History'}
</button>
</div>
</div>
Expand Down
23 changes: 12 additions & 11 deletions src/lib/components/editors/DagView.css
Original file line number Diff line number Diff line change
@@ -1,39 +1,40 @@
.dag-view-message:hover {
color: #777;
background-color: rgba(139, 92, 246, 0.2);
cursor: pointer;
border-radius: 8px;
padding: 4px 8px;
}

.dag-view-message {
color: #333;
color: rgba(255, 255, 255, 0.9);
padding: 4px 8px;
transition: all 0.2s ease;
}

.dag-view-message .author {
color: #777;
color: rgba(255, 255, 255, 0.6);
margin-left: 0.8em;
}

.dag-view-message:hover .author {
color: #aaa;
margin-left: 0.8em;
color: rgba(255, 255, 255, 0.8);
}

.dag-view-message .operationType {
color: #777;
color: rgba(255, 255, 255, 0.6);
margin-left: 0.8em;
}

.dag-view-message:hover .operationType {
color: #aaa;
margin-left: 0.8em;
color: rgba(255, 255, 255, 0.8);
}

.dag-view-message .timestamp {
color: #777;
color: rgba(255, 255, 255, 0.6);
margin-left: 0.8em;
}

.dag-view-message:hover .timestamp {
color: #aaa;
margin-left: 0.8em;
color: rgba(255, 255, 255, 0.8);
}

2 changes: 1 addition & 1 deletion src/lib/components/editors/editor-history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export function convertSyncStepsToNodes(
deps,
lamport: change.lamport,
message: `Change at ${change.counter} (length: ${change.length})`,
author: change.peer || '',
// author: change.peer || '',
timestamp: change.timestamp ? change.timestamp * 1000 : Date.now()
});

Expand Down
6 changes: 3 additions & 3 deletions src/routes/(app)/[username]/[slug]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
</title>
</svelte:head>

<main class="mx-4 flex w-full max-w-[800px] flex-col items-center px-2 font-spacemono">
<main class="mx-4 flex w-full flex-col items-center px-2 font-spacemono">
<div
class="relative m-4 mt-12 flex w-full flex-col justify-center gap-4 rounded-xl border-[1px] border-black bg-pink-300/10 p-8 text-xl"
>
Expand Down Expand Up @@ -141,7 +141,7 @@
</form>
{/if}

<div class="absolute right-8 top-8 z-10 flex gap-2">
<div class="absolute right-8 top-8 z-10 flex gap-z">
{#if data.profileMatchesUserSession || data.page.wiki}
{#if !editingState.editing}
<button
Expand Down Expand Up @@ -178,7 +178,7 @@

<div class="flex flex-col gap-8">
<div
class="prose relative mx-auto w-full max-w-2xl px-4 pt-4 dark:prose-invert prose-a:text-blue-400"
class="prose relative mx-auto w-full max-w-[1000px] pt-4 dark:prose-invert prose-a:text-blue-400"
>
{#if !editingState.editing}
{@html renderMarkdownSanitized(data.page.markdown)}
Expand Down

0 comments on commit 6f22ddf

Please sign in to comment.