-
-
Notifications
You must be signed in to change notification settings - Fork 10
🎨 Improve table layout (#1526) #1545
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughThe changes in this pull request involve modifications to the Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant TaskList
participant WorkBookTasksTable
participant Page
User->>Page: View Workbook
Page->>TaskList: Render Task List
TaskList->>TaskList: Apply table-fixed layout
TaskList->>User: Display tasks
User->>WorkBookTasksTable: View Task Details
WorkBookTasksTable->>WorkBookTasksTable: Apply table-fixed layout
WorkBookTasksTable->>User: Display task grades and comments
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Outside diff range and nitpick comments (6)
src/routes/workbooks/[slug]/+page.svelte (2)
145-149: LGTM: Well-structured responsive column widthsThe column width distribution is well thought out:
- Fixed widths for compact columns (grade, answer, comment)
- Proportional widths for content-heavy columns (problem, source)
- Responsive adjustments for mobile views
Consider adding a comment above the TableHead to document the column width distribution for future maintainability.
197-198: Simplify the comment/hint column layoutWhile the current implementation works, the nested flex container could be simplified.
Consider this simpler structure:
-<TableBodyCell class="justify-center w-14 px-0.5"> - <div class="flex items-center justify-center"> +<TableBodyCell class="w-14 px-0.5 flex items-center justify-center">src/lib/components/TaskList.svelte (2)
58-63: Consider enhancing text overflow handlingWhile the width distribution is well-thought-out, very long content might still cause layout issues. Consider adding these improvements:
- <TableHeadCell class="w-20 sm:w-24">回答</TableHeadCell> - <TableHeadCell class="w-1/2 text-left pl-0 sm:pl-6 truncate">問題名</TableHeadCell> + <TableHeadCell class="w-20 sm:w-24 min-w-[5rem]">回答</TableHeadCell> + <TableHeadCell class="w-1/2 text-left pl-0 sm:pl-6 truncate overflow-ellipsis">問題名</TableHeadCell>
Line range hint
97-110: Address the TODO comment about explanation viewingThere's an unimplemented feature for viewing explanations in the non-admin view.
Would you like me to help implement the explanation viewing feature or create a GitHub issue to track this enhancement?
src/lib/components/WorkBookTasks/WorkBookTasksTable.svelte (2)
114-125: Consider using fixed widths instead of proportional widths for better layout stabilityWhile the table layout improvements are good, mixing fixed widths (
w-6,w-20) with proportional widths (w-1/2,w-1/3) might cause layout issues. Consider using fixed widths for all columns or ensuring the proportions add up correctly.- <TableHeadCell class="w-1/2 pl-0 truncate">問題名</TableHeadCell> - <TableHeadCell class="w-1/3 hidden sm:table-cell truncate">出典</TableHeadCell> + <TableHeadCell class="w-96 pl-0 truncate">問題名</TableHeadCell> + <TableHeadCell class="w-64 hidden sm:table-cell truncate">出典</TableHeadCell>
163-165: Consider adding aria-hidden for better accessibilityWhen hiding elements on mobile with
hidden sm:table-cell, consider addingaria-hidden="true"for better screen reader support.<TableBodyCell - class="xs:text-lg hidden sm:table-cell text-gray-700 dark:text-gray-300 truncate" + class="xs:text-lg hidden sm:table-cell text-gray-700 dark:text-gray-300 truncate" + aria-hidden="true" >
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (3)
src/lib/components/TaskList.svelte(3 hunks)src/lib/components/WorkBookTasks/WorkBookTasksTable.svelte(5 hunks)src/routes/workbooks/[slug]/+page.svelte(4 hunks)
🔇 Additional comments (8)
src/routes/workbooks/[slug]/+page.svelte (4)
143-143: LGTM: Improved table layout with fixed-width columns
The addition of table-fixed and w-full classes ensures consistent column widths and proper table sizing.
158-158: LGTM: Consistent width constraints
The cell width matches its header and the inner constraints maintain the grade label's shape.
178-178: LGTM: Well-structured problem link cell
Good implementation of:
- Consistent width with header
- Proper text truncation
- Responsive padding
190-190: LGTM: Responsive source column implementation
Good implementation of:
- Consistent width with header
- Proper responsive visibility
- Text truncation
src/lib/components/TaskList.svelte (3)
56-56: Good choice of table layout strategy!
The addition of table-fixed with w-full provides better control over column widths while ensuring the table uses the available space effectively.
Line range hint 81-94: Excellent responsive design implementation!
The cell widths perfectly align with headers, and the responsive classes provide a good mobile experience. The dark mode support is also well implemented.
Line range hint 56-110: Verify consistent table layout across components
Let's ensure the table layout improvements are consistent with other components mentioned in the PR.
✅ Verification successful
Table layouts are consistent with minor variations for specific use cases
The table layouts across components follow a consistent pattern with appropriate width distributions:
- All tables use the same base structure with
TableHead,TableHeadCell, and responsive classes - Width allocations are contextually appropriate:
- TaskList: w-20/w-1/2/w-1/3/w-6 for answer/name/source/edit
- WorkBookTasksTable: Similar pattern with additional columns
- Other components (TaskListSorted, TaskListForEdit, etc.) use fractional widths (w-1/6, w-1/3, etc.) appropriate for their content
The variations in column widths are justified by the different content requirements of each table, while maintaining a consistent structural approach.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for similar table implementations in related components
rg -l "Table.*class=\".*table-fixed.*\"" src/lib/components/
rg -l "TableHeadCell.*class=\".*w-\d" src/lib/components/
Length of output: 465
Script:
#!/bin/bash
# Check table layout patterns in the identified files
for file in src/lib/components/TaskList.svelte src/lib/components/WorkBookTasks/WorkBookTasksTable.svelte; do
echo "=== $file ==="
rg "TableHead.*class.*" "$file" -A 5
done
# Check column width patterns
for file in src/lib/components/TagListForEdit.svelte src/lib/components/TaskListSorted.svelte src/lib/components/TaskListForEdit.svelte src/lib/components/TagForm.svelte; do
echo "=== $file ==="
rg "TableHeadCell.*class.*w-\d.*" "$file" -A 1
done
Length of output: 4202
src/lib/components/WorkBookTasks/WorkBookTasksTable.svelte (1)
145-146: LGTM! Good alignment improvements
The added width classes and flex container improve the alignment and consistency of the grade column.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (1)
src/lib/components/WorkBookTasks/WorkBookTasksTable.svelte (1)
123-125: Enhance accessibility furtherWhile the current accessibility improvements are good, consider:
- Adding aria-sort for sortable columns
- Using aria-describedby for cells with additional context
- Adding table caption for screen readers
Example:
+ <Table shadow class="text-md table-fixed w-full" aria-label="Workbook tasks"> + <caption class="sr-only">List of workbook tasks with their grades and comments</caption>Also applies to: 131-133, 171-172
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (2)
src/lib/components/TaskList.svelte(3 hunks)src/lib/components/WorkBookTasks/WorkBookTasksTable.svelte(8 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- src/lib/components/TaskList.svelte
🔇 Additional comments (4)
src/lib/components/WorkBookTasks/WorkBookTasksTable.svelte (4)
2-2: Good security improvement with XSS protection!
The addition of XSS sanitization for user input is a great security enhancement. The implementation correctly sanitizes the input before performing the length validation.
Also applies to: 38-46
120-128: Well-structured table layout with responsive design!
The table layout improvements with fixed widths and responsive classes will provide a better user experience:
table-fixedprevents unwanted column width calculations- Specific width classes (
w-6,w-20, etc.) ensure consistent column sizes - Responsive hiding with
hidden sm:table-cellmaintains usability on mobile
112-112: Improved delete action implementation!
The delete action now includes:
- Confirmation dialog to prevent accidental deletions
- Loading state during deletion
- Icon-based button for better visual appeal
Also applies to: 193-211
Line range hint 183-189: Consider replacing contenteditable with input element
While the responsive design improvement is good, consider implementing the previously suggested input-based approach for better:
- User experience
- Input validation
- Character count visibility
KATO-Hiro
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Summary by CodeRabbit