diff --git a/blocks/table/table.css b/blocks/table/table.css index de1df9a5..1dcac7cf 100644 --- a/blocks/table/table.css +++ b/blocks/table/table.css @@ -33,3 +33,124 @@ .table.striped tbody tr:nth-child(odd) { background-color: var(--color-gray-200); } + +/* Comparison variant: heading row + heading column, 2x first column width */ +.table.comparison .table-comparison-scroll { + width: 100%; + overflow-x: auto; + -webkit-overflow-scrolling: touch; +} + +.table.comparison .table-comparison-scroll table { + width: 100%; + min-width: 600px; + table-layout: fixed; + border-collapse: collapse; + border: 1px solid #e0e0e0; +} + +.table.comparison .table-comparison-scroll th, +.table.comparison .table-comparison-scroll td { + padding: 16px 12px; + border: 1px solid #e0e0e0; + vertical-align: top; +} + +.table.comparison .table-comparison-scroll thead th { + background-color: #ececec; + font-weight: 700; + text-align: center; + color: #333; +} + +.table.comparison .table-comparison-scroll tbody th { + background-color: #fff; + font-weight: 600; + text-align: left; + color: #333; + vertical-align: middle; +} + +.table.comparison .table-comparison-scroll thead th:first-child { + text-align: left; + color: #6c757d; + font-weight: 600; +} + +/* Heading column: flex on
, image left, text right, vertically centered */ +.table.comparison .table-comparison-scroll tbody th .table-comparison-cell-content p { + display: flex; + align-items: center; + gap: 12px; + margin: 0; +} + +.table.comparison .table-comparison-scroll tbody th .table-comparison-cell-content p picture, +.table.comparison .table-comparison-scroll tbody th .table-comparison-cell-content p img { + flex-shrink: 0; + width: 48px; + height: 48px; + margin: 0; +} + +.table.comparison .table-comparison-scroll tbody th .table-comparison-cell-content p img { + width: 48px; + height: 48px; + object-fit: contain; +} + +.table.comparison .table-comparison-scroll tbody th .table-comparison-cell-content p a { + color: #06c; + text-decoration: none; + flex: 1; + min-width: 0; +} + +.table.comparison .table-comparison-scroll tbody th .table-comparison-cell-content p a:hover { + text-decoration: underline; +} + +.table.comparison .table-comparison-scroll tbody td { + background-color: #fff; + text-align: center; + color: #333; +} + +.table.comparison .table-comparison-scroll thead tr.table-comparison-row-header-empty th, +.table.comparison .table-comparison-scroll tbody tr.table-comparison-row-header-empty th, +.table.comparison .table-comparison-scroll tbody tr.table-comparison-row-header-empty td { + background-color: transparent; + border-color: transparent; +} + +/* Comparison table: colors row – round swatches from pdp/color-swatches.css */ +.table.comparison .table-comparison-scroll .table-comparison-color-swatches { + display: flex; + flex-wrap: wrap; + align-items: center; + justify-content: center; + gap: 6px; +} + +.table.comparison .table-comparison-scroll .table-comparison-color-swatch { + width: 24px; + height: 24px; + border: 1px solid #333f48; + border-radius: 50%; + display: flex; + align-items: center; + justify-content: center; + box-sizing: border-box; +} + +.table.comparison .table-comparison-scroll .table-comparison-color-inner { + width: 16px; + height: 16px; + border: 1px solid #333f48; + border-radius: 50%; +} + +.table.comparison .table-comparison-scroll .table-comparison-color-text { + font-size: 0.9em; + color: #666; +} diff --git a/blocks/table/table.js b/blocks/table/table.js index afe00f81..74decde2 100644 --- a/blocks/table/table.js +++ b/blocks/table/table.js @@ -1,3 +1,40 @@ +import { toClassName } from '../../scripts/aem.js'; + +const COLOR_SWATCHES_CSS_PATH = '/blocks/pdp/color-swatches.css'; + +/** + * Fetch color-swatches.css, parse --color-* names and the rule body, inject a scoped + *