File tree Expand file tree Collapse file tree 5 files changed +121
-7
lines changed Expand file tree Collapse file tree 5 files changed +121
-7
lines changed Original file line number Diff line number Diff line change @@ -570,6 +570,41 @@ const Hooks = {
570
570
} ) ;
571
571
} ,
572
572
} ,
573
+ ExpandableText : {
574
+ mounted ( ) {
575
+ const button = document . querySelector ( `#${ this . el . dataset . expandId } ` ) ;
576
+
577
+ // Check if content is truncated
578
+ const isTruncated = this . el . scrollHeight > this . el . clientHeight ;
579
+
580
+ if ( isTruncated && button ) {
581
+ button . classList . remove ( "hidden" ) ;
582
+ }
583
+ } ,
584
+ } ,
585
+
586
+ ExpandableTextButton : {
587
+ mounted ( ) {
588
+ this . el . addEventListener ( "click" , ( ) => {
589
+ const content = document . querySelector < HTMLElement > (
590
+ `#${ this . el . dataset . contentId } `
591
+ ) ;
592
+ if ( ! content ) return ;
593
+
594
+ const className = content . dataset . class ;
595
+
596
+ if ( content . classList . contains ( className ) ) {
597
+ // Expand
598
+ content . classList . remove ( className ) ;
599
+ this . el . classList . add ( "hidden" ) ;
600
+ } else {
601
+ // Collapse
602
+ content . classList . add ( className ) ;
603
+ this . el . classList . remove ( "hidden" ) ;
604
+ }
605
+ } ) ;
606
+ } ,
607
+ } ,
573
608
} satisfies Record < string , Partial < ViewHook > & Record < string , unknown > > ;
574
609
575
610
// Accessible focus handling
Original file line number Diff line number Diff line change @@ -180,8 +180,28 @@ defmodule AlgoraWeb.HomeLive do
180
180
{ job . title }
181
181
</ div >
182
182
</ div >
183
- < div :if = { job . description } class = "pt-1 text-sm text-muted-foreground " >
184
- { job . description }
183
+ < div
184
+ :if = { job . description }
185
+ class = "pt-1 text-sm text-muted-foreground prose prose-invert max-w-none "
186
+ >
187
+ < div
188
+ id = { "job-description-#{ job . id } " }
189
+ class = "line-clamp-2 transition-all duration-200 "
190
+ phx-hook = "ExpandableText "
191
+ data-expand-id = { "expand-#{ job . id } " }
192
+ data-class = "line-clamp-2 "
193
+ >
194
+ { Phoenix.HTML . raw ( Algora.Markdown . render ( job . description ) ) }
195
+ </ div >
196
+ < button
197
+ id = { "expand-#{ job . id } " }
198
+ type = "button "
199
+ class = "text-xs text-foreground font-bold mt-2 hidden "
200
+ data-content-id = { "job-description-#{ job . id } " }
201
+ phx-hook = "ExpandableTextButton "
202
+ >
203
+ ...see more
204
+ </ button >
185
205
</ div >
186
206
< div class = "pt-2 flex flex-wrap gap-2 " >
187
207
<%= for tech <- job . tech_stack do %>
@@ -318,7 +338,11 @@ defmodule AlgoraWeb.HomeLive do
318
338
</ h3 >
319
339
< div class = "flex flex-wrap items-center gap-x-8 gap-y-4 pt-4 sm:pt-6 " >
320
340
< div class = "flex items-center gap-4 " >
321
- < img src = "https://github.com/mschuwalow.png " class = "h-12 w-12 rounded-full " loading = "lazy " />
341
+ < img
342
+ src = "https://github.com/mschuwalow.png "
343
+ class = "h-12 w-12 rounded-full "
344
+ loading = "lazy "
345
+ />
322
346
< div >
323
347
< div class = "text-xl sm:text-2xl font-semibold text-foreground " >
324
348
Maxim Schuwalow
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ defmodule AlgoraWeb.JobsLive do
8
8
alias Algora.Accounts
9
9
alias Algora.Jobs
10
10
alias Algora.Jobs.JobPosting
11
+ alias Algora.Markdown
11
12
alias Phoenix.LiveView.AsyncResult
12
13
13
14
require Logger
@@ -112,8 +113,28 @@ defmodule AlgoraWeb.JobsLive do
112
113
{ job . title }
113
114
</ div >
114
115
</ div >
115
- < div :if = { job . description } class = "pt-1 text-sm text-muted-foreground " >
116
- { job . description }
116
+ < div
117
+ :if = { job . description }
118
+ class = "pt-1 text-sm text-muted-foreground prose prose-invert max-w-none "
119
+ >
120
+ < div
121
+ id = { "job-description-#{ job . id } " }
122
+ class = "line-clamp-3 transition-all duration-200 "
123
+ phx-hook = "ExpandableText "
124
+ data-expand-id = { "expand-#{ job . id } " }
125
+ data-class = "line-clamp-3 "
126
+ >
127
+ { Phoenix.HTML . raw ( Markdown . render ( job . description ) ) }
128
+ </ div >
129
+ < button
130
+ id = { "expand-#{ job . id } " }
131
+ type = "button "
132
+ class = "text-xs text-foreground font-bold mt-2 hidden "
133
+ data-content-id = { "job-description-#{ job . id } " }
134
+ phx-hook = "ExpandableTextButton "
135
+ >
136
+ ...see more
137
+ </ button >
117
138
</ div >
118
139
< div class = "pt-2 flex flex-wrap gap-2 " >
119
140
<%= for tech <- job . tech_stack do %>
Original file line number Diff line number Diff line change @@ -176,7 +176,24 @@ defmodule AlgoraWeb.Org.JobLive do
176
176
:if = { @ job . description }
177
177
class = "pt-1 text-sm text-muted-foreground prose prose-invert max-w-none "
178
178
>
179
- { Phoenix.HTML . raw ( Markdown . render ( @ job . description ) ) }
179
+ < div
180
+ id = { "job-description-#{ @ job . id } " }
181
+ class = "line-clamp-3 transition-all duration-200 "
182
+ phx-hook = "ExpandableText "
183
+ data-expand-id = { "expand-#{ @ job . id } " }
184
+ data-class = "line-clamp-3 "
185
+ >
186
+ { Phoenix.HTML . raw ( Markdown . render ( @ job . description ) ) }
187
+ </ div >
188
+ < button
189
+ id = { "expand-#{ @ job . id } " }
190
+ type = "button "
191
+ class = "text-xs text-foreground font-bold mt-2 hidden "
192
+ data-content-id = { "job-description-#{ @ job . id } " }
193
+ phx-hook = "ExpandableTextButton "
194
+ >
195
+ ...see more
196
+ </ button >
180
197
</ div >
181
198
< div class = "pt-2 flex flex-wrap gap-2 " >
182
199
<%= for tech <- @ job . tech_stack do %>
Original file line number Diff line number Diff line change @@ -117,7 +117,24 @@ defmodule AlgoraWeb.Org.JobsLive do
117
117
:if = { job . description }
118
118
class = "pt-1 text-sm text-muted-foreground prose prose-invert max-w-none "
119
119
>
120
- { Phoenix.HTML . raw ( Markdown . render ( job . description ) ) }
120
+ < div
121
+ id = { "job-description-#{ job . id } " }
122
+ class = "line-clamp-3 transition-all duration-200 "
123
+ phx-hook = "ExpandableText "
124
+ data-expand-id = { "expand-#{ job . id } " }
125
+ data-class = "line-clamp-3 "
126
+ >
127
+ { Phoenix.HTML . raw ( Markdown . render ( job . description ) ) }
128
+ </ div >
129
+ < button
130
+ id = { "expand-#{ job . id } " }
131
+ type = "button "
132
+ class = "text-xs text-foreground font-bold mt-2 hidden "
133
+ data-content-id = { "job-description-#{ job . id } " }
134
+ phx-hook = "ExpandableTextButton "
135
+ >
136
+ ...see more
137
+ </ button >
121
138
</ div >
122
139
< div class = "pt-2 flex flex-wrap gap-2 " >
123
140
<%= for tech <- job . tech_stack do %>
You can’t perform that action at this time.
0 commit comments