Skip to content

Commit 37e159f

Browse files
committed
Refactor user views to avoid inline stylings
1 parent d6f639d commit 37e159f

File tree

7 files changed

+435
-405
lines changed

7 files changed

+435
-405
lines changed

app/assets/tailwind/application.css

Lines changed: 232 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,10 +278,242 @@ nav.pagy a.gap {
278278
@apply border-l-2 border-r-2 bg-white;
279279
}
280280

281+
/* Layout Utilities */
282+
.page-container {
283+
min-height: 100vh;
284+
padding: 2rem 0;
285+
}
286+
287+
.content-wrapper {
288+
max-width: 1200px;
289+
margin: 0 auto;
290+
padding: 0 1rem;
291+
overflow-x: hidden;
292+
}
293+
294+
.section-spacing {
295+
margin-bottom: 2rem;
296+
}
297+
298+
.section-spacing-lg {
299+
margin-bottom: 2.5rem;
300+
}
301+
302+
/* Flexbox Utilities */
303+
.flex-between {
304+
@apply flex justify-between items-center;
305+
}
306+
307+
.flex-between-wrap {
308+
@apply flex justify-between items-center flex-wrap gap-4;
309+
}
310+
311+
.flex-center {
312+
@apply flex items-center gap-4;
313+
}
314+
315+
.flex-center-sm {
316+
@apply flex items-center gap-2;
317+
}
318+
319+
/* Card Components */
320+
.card-elevated {
321+
@apply bg-white rounded-2xl shadow-lg border border-gray-200;
322+
}
323+
324+
.card-header-gradient {
325+
background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
326+
@apply p-6 text-white;
327+
}
328+
329+
.card-body {
330+
@apply p-8;
331+
}
332+
333+
.card-body-sm {
334+
@apply p-6;
335+
}
336+
337+
/* Icon Containers */
338+
.icon-wrapper {
339+
@apply p-3 rounded-xl flex-shrink-0;
340+
}
341+
342+
.icon-wrapper-sm {
343+
@apply p-2 rounded-lg;
344+
}
345+
346+
.icon-wrapper-translucent {
347+
background: rgba(255, 255, 255, 0.2);
348+
@apply p-2 rounded-lg;
349+
}
350+
351+
.icon-size {
352+
@apply w-4 h-4;
353+
}
354+
355+
.icon-size-md {
356+
@apply w-5 h-5;
357+
}
358+
359+
.icon-size-lg {
360+
@apply w-6 h-6;
361+
}
362+
363+
/* Typography */
364+
.page-title {
365+
@apply text-4xl font-bold text-gray-800 m-0;
366+
}
367+
368+
.page-subtitle {
369+
@apply text-gray-500 m-0 text-base;
370+
}
371+
372+
.section-title {
373+
@apply text-xl font-semibold m-0;
374+
}
375+
376+
.form-label-styled {
377+
@apply block font-semibold text-gray-700 mb-3 text-sm;
378+
}
379+
380+
.label-with-icon {
381+
@apply flex items-center gap-2;
382+
}
383+
384+
.text-required {
385+
@apply text-red-600;
386+
}
387+
388+
.text-muted {
389+
@apply text-gray-500 text-xs mt-2;
390+
}
391+
392+
/* Error/Alert Components */
393+
.alert-error {
394+
@apply bg-red-50 border border-red-200 rounded-xl p-6 mb-8;
395+
}
396+
397+
.alert-error-title {
398+
@apply text-red-600 font-semibold m-0 text-base;
399+
}
400+
401+
.alert-error-list {
402+
@apply m-0 pl-6 text-red-600 text-sm;
403+
}
404+
405+
/* Breadcrumb */
406+
.breadcrumb-nav {
407+
@apply text-sm text-gray-500;
408+
}
409+
410+
.breadcrumb-list {
411+
@apply flex gap-2 list-none p-0 m-0;
412+
}
413+
414+
.breadcrumb-separator {
415+
@apply text-gray-300;
416+
}
417+
418+
.breadcrumb-current {
419+
@apply text-gray-700 font-medium;
420+
}
421+
422+
/* Grid Layouts */
423+
.form-grid {
424+
@apply grid gap-8;
425+
}
426+
427+
.form-grid-auto {
428+
display: grid;
429+
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
430+
gap: 1.5rem;
431+
}
432+
433+
/* Info Panel */
434+
.info-panel {
435+
@apply bg-gray-50 border-2 border-gray-200 rounded-xl p-6;
436+
}
437+
438+
/* Table Styles */
439+
.table-header {
440+
@apply py-5 px-6 text-left text-xs font-bold text-slate-600 uppercase tracking-wider;
441+
}
442+
443+
.table-cell {
444+
@apply py-5 px-6;
445+
}
446+
447+
.user-avatar {
448+
@apply w-10 h-10 bg-gradient-to-br from-indigo-500 to-indigo-600 rounded-full flex items-center justify-center text-white font-semibold text-sm;
449+
}
450+
451+
.badge-admin {
452+
@apply inline-flex items-center gap-1.5 bg-gradient-to-br from-red-600 to-red-700 text-white py-1.5 px-3 rounded-full text-xs font-semibold;
453+
}
454+
455+
.badge-contributor {
456+
@apply inline-flex items-center gap-1.5 text-white py-1.5 px-3 rounded-full text-xs font-semibold;
457+
}
458+
459+
.badge-provider {
460+
@apply text-white py-1 px-2 rounded-full font-semibold;
461+
font-size: 0.625rem;
462+
}
463+
464+
.btn-view {
465+
@apply bg-blue-500 text-white py-2 px-3 rounded-md no-underline text-xs font-semibold inline-flex items-center gap-1.5 transition-all hover:bg-blue-600;
466+
}
467+
468+
.btn-edit {
469+
@apply bg-gray-500 text-white py-2 px-3 rounded-md no-underline text-xs font-semibold inline-flex items-center gap-1.5 transition-all hover:bg-gray-600;
470+
}
471+
472+
.empty-state {
473+
@apply p-12 px-6 text-center;
474+
}
475+
476+
.pagination-footer {
477+
@apply bg-gray-50 p-6 border-t border-gray-200 flex justify-between items-center;
478+
}
479+
480+
/* Form Container */
481+
.form-container {
482+
max-width: 800px;
483+
margin: 0 auto;
484+
padding: 0 1rem;
485+
}
486+
487+
/* Success Alert */
488+
.alert-success {
489+
@apply bg-green-50 border border-green-200 text-green-700 p-4 rounded-lg mb-8;
490+
}
491+
281492
nav.pagy a:hover:not(.current):not(.gap) {
282493
@apply bg-blue-800 text-white border-blue-800;
283494
}
284495

285496
nav.pagy a.current {
286497
@apply bg-blue-600 text-white border-blue-600 font-semibold;
287498
}
499+
500+
/* Responsive Table Styles */
501+
@media (max-width: 768px) {
502+
.hide-mobile {
503+
display: none !important;
504+
}
505+
.table-container table {
506+
table-layout: auto !important;
507+
}
508+
}
509+
510+
.table-container table td:not(.actions-col),
511+
.table-container table th:not(.actions-col) {
512+
word-wrap: break-word;
513+
word-break: break-word;
514+
overflow-wrap: anywhere;
515+
}
516+
517+
.table-container table td.actions-col {
518+
white-space: nowrap;
519+
}

app/views/shared/_errors.html.erb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
<% if errors.any? %>
2-
<div style="background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; padding: 1rem; border-radius: 0.5rem; margin-bottom: 1.5rem;">
3-
<div style="display: flex; gap: 0.75rem;">
4-
<svg style="width: 1.25rem; height: 1.25rem; color: #ef4444; flex-shrink: 0; margin-top: 0.125rem;" fill="none" stroke="currentColor" viewBox="0 0 24 24">
2+
<div class="bg-red-50 border border-red-200 text-red-900 p-4 rounded-lg mb-6">
3+
<div class="flex gap-3">
4+
<svg class="icon-size-md text-red-500 flex-shrink-0 mt-0.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
55
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path>
66
</svg>
7-
<div style="flex: 1;">
8-
<h4 style="font-weight: 600; color: #991b1b; margin: 0 0 0.5rem 0; font-size: 0.875rem;">
7+
<div class="flex-1">
8+
<h4 class="font-semibold text-red-900 m-0 mb-2 text-sm">
99
<%= pluralize(errors.count, "error") %> prevented this <%= resource_name.downcase %> from being saved:
1010
</h4>
11-
<ul style="list-style: none; padding: 0; margin: 0; space-y: 0.25rem;">
11+
<ul class="list-none p-0 m-0 space-y-1">
1212
<% errors.each do |error| %>
13-
<li style="font-size: 0.75rem; color: #7f1d1d; margin-bottom: 0.25rem; display: flex; align-items: flex-start; gap: 0.5rem;">
14-
<span style="color: #ef4444; font-weight: bold; margin-top: 0.125rem;"></span>
13+
<li class="text-xs text-red-800 mb-1 flex items-start gap-2">
14+
<span class="text-red-500 font-bold mt-0.5"></span>
1515
<span><%= error %></span>
1616
</li>
1717
<% end %>

0 commit comments

Comments
 (0)