Skip to content
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

fix(#1247): replace some @media queries with @container #1451

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v14.16.1
v16.20.2
22 changes: 22 additions & 0 deletions libs/web-components/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion libs/web-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@
"directory": "libs/web-components"
},
"devDependencies": {
"@csstools/postcss-global-data": "^2.1.0",
"@rollup/plugin-commonjs": "^20.0.0",
"@rollup/plugin-node-resolve": "^13.0.4",
"@rollup/plugin-typescript": "^8.0.0",
"@tsconfig/svelte": "^2.0.0",
"postcss-replace": "^2.0.1",
"rollup": "^2.0.0",
"rollup-plugin-clean": "^1.0.0",
"rollup-plugin-css-only": "^3.1.0",
Expand Down
53 changes: 38 additions & 15 deletions libs/web-components/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ import preprocess from "svelte-preprocess";
import commonjs from "@rollup/plugin-commonjs";
import typescript from "@rollup/plugin-typescript";
import css from "rollup-plugin-css-only";
import { replaceCodePlugin } from "vite-plugin-replace";
import postcssGlobalData from "@csstools/postcss-global-data";
import autoprefixer from "autoprefixer";
import postcssCustomMedia from "postcss-custom-media";

export default {
input: "src/index.ts",
Expand All @@ -27,11 +24,45 @@ export default {
sourceMap: true,
postcss: {
plugins: [
postcssGlobalData({
files: ["./src/assets/css/breakpoints.css"],
}),
postcssReplace([
{
pattern: /\(--mobile\)/g,
data: {
replaceAll: "(max-width: 623px)"
},
},
{
pattern: /\(--not-mobile\)/g,
data: {
replaceAll: "(min-width: 624px)",
}
},
{
pattern: /\(--tablet\)/,
data: {
replaceAll: "(min-width: 624px) and (max-width: 1023px)",
}
},
{
pattern: /\(--not-tablet\)/,
data: {
replaceAll: "(max-width: 623px) or (min-width: 1024px)",
}
},
{
pattern: /\(--desktop\)/,
data: {
replaceAll: "(min-width: 1024px)",
}
},
{
pattern: /\(--not-desktop\)/,
data: {
replaceAll: "(max-width: 1023px)",
}
},
]),
autoprefixer(),
postcssCustomMedia(),
],
},
}),
Expand All @@ -49,14 +80,6 @@ export default {
resolve(),
terser(),
summary(),
replaceCodePlugin({
replacements: [
{
from: /:global\(([\[\]\(\)\-\.\:\*\w]+)\)/g,
to: "$1",
},
],
}),
],
watch: {
clearScreen: true,
Expand Down
47 changes: 41 additions & 6 deletions libs/web-components/rollup.playground.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ import livereload from "rollup-plugin-livereload";
import css from "rollup-plugin-css-only";
import preprocess from "svelte-preprocess";
import typescript from "@rollup/plugin-typescript";
import postcssGlobalData from "@csstools/postcss-global-data";
import autoprefixer from "autoprefixer";
import postcssCustomMedia from "postcss-custom-media";
import postcssReplace from "postcss-replace";

function serve() {
let server;
Expand Down Expand Up @@ -52,11 +51,47 @@ export default {
sourceMap: true,
postcss: {
plugins: [
postcssGlobalData({
files: ["./src/assets/css/breakpoints.css"],
}),
postcssReplace([
{
pattern: /\(--mobile\)/g,
data: {
replaceAll: "(max-width: 623px)"
},
},
{
pattern: /\(--not-mobile\)/g,
data: {
replaceAll: "(min-width: 624px)",
}
},

{
pattern: /\(--tablet\)/,
data: {
replaceAll: "(min-width: 624px) and (max-width: 1023px)",
}
},
{
pattern: /\(--not-tablet\)/,
data: {
replaceAll: "(max-width: 623px) or (min-width: 1024px)",
}
},
{
pattern: /\(--desktop\)/,
data: {
replaceAll: "(min-width: 1024px)",
}
},
{
pattern: /\(--not-desktop\)/,
data: {
replaceAll: "(max-width: 1023px)",
}
},
]),

autoprefixer(),
postcssCustomMedia(),
],
},
}),
Expand Down
3 changes: 0 additions & 3 deletions libs/web-components/src/assets/css/breakpoints.css

This file was deleted.

116 changes: 54 additions & 62 deletions libs/web-components/src/components/accordion/Accordion.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<svelte:options tag="goa-accordion" />

Check warning on line 1 in libs/web-components/src/components/accordion/Accordion.svelte

View workflow job for this annotation

GitHub Actions / build

The 'tag' option is used when generating a custom element. Did you forget the 'customElement: true' compile option?

<!-- Script -->
<script lang="ts">
Expand Down Expand Up @@ -65,10 +65,11 @@
on:focus={() => _hovering = false}
on:blur={() => _hovering = false}
>
<goa-icon type="chevron-forward"
<goa-icon
type="chevron-forward"
fillcolor={_hovering?"var(--goa-color-interactive-hover)": "var(--goa-color-interactive-default)"}
></goa-icon>
<div class="title" bind:this={_titleEl}>
/>
<div class="title">
<span class="heading heading-{headingsize}" data-testid={`${testid}-heading`}>{heading}</span>
<span class="secondary-text">{secondarytext}</span>
<div class="heading-content"
Expand Down Expand Up @@ -113,63 +114,95 @@
position: relative;
}

summary.container-medium {
min-height: 4rem;
summary:hover {
background-color: var(--goa-color-greyscale-200);
}

summary:focus,
summary:active {
background-color: var(--goa-color-greyscale-100);
outline: none;
}

/* Hack to make outline radius work on Safari */
summary:active::before,
summary:focus::before {
content: "";
position: absolute;
top: -1px;
right: -1px;
bottom: -1px;
left: -1px;
border: var(--goa-border-width-l) solid var(--goa-color-interactive-focus);
border-radius: 4px;
}

summary::marker, /* Latest Chrome, Edge, Firefox */
summary::-webkit-details-marker /* Safari */ {
display: none;
}

summary .title{
.container-medium {
min-height: 4rem;
}

.title {
display: flex;
align-items: center;
flex: 1;
}

@container (--mobile) {
.title {
flex-direction: column;
}
}

@container (--not-mobile) {
.title {
align-items: center;
}
}

.title span {
padding-bottom: var(--goa-space-3xs, 0);
}

summary .heading {
.heading {
font: var(--goa-typography-heading-s);
padding-right: 1rem;
}

summary .secondary-text {
.secondary-text {
font: var(--goa-typography-body-s);
line-height: 1.5rem;
padding-right: 1rem;
}

summary .heading-content {
.heading-content {
flex: 1
}

summary goa-icon{
padding: 0.125rem 1rem;
}

.container-medium goa-icon{
padding: 0.375rem 1rem;
}

.content {
border-bottom: var(--goa-border-width-s) solid var(--goa-color-greyscale-200);
border-left: var(--goa-border-width-s) solid var(--goa-color-greyscale-200);
border-right: var(--goa-border-width-s) solid var(--goa-color-greyscale-200);
border-bottom-left-radius: var(--goa-border-radius-m);
border-bottom-right-radius: var(--goa-border-radius-m);
padding: 1.5rem;
padding-left: 3.5rem;
padding-right: 2rem;
}

.content ::slotted(p:last-child) {
margin-bottom: 0 !important;
}

summary goa-icon{
padding: 0.125rem 1rem;
}

summary.container-medium goa-icon{
padding: 0.375rem 1rem;
}

details[open] goa-icon {
transform: rotate(90deg);
}
Expand All @@ -179,51 +212,10 @@
border-bottom-right-radius: var(--goa-border-radius-none);
}

summary:hover {
background-color: var(--goa-color-greyscale-200);
}

summary:focus,
summary:active {
background-color: var(--goa-color-greyscale-100);
outline: none;
}

/* Hack to make outline radius work on Safari */
summary:active::before,
summary:focus::before {
content: "";
position: absolute;
top: -1px;
right: -1px;
bottom: -1px;
left: -1px;
border: var(--goa-border-width-l) solid var(--goa-color-interactive-focus);
border-radius: 4px;
}

/* Sizes */
summary .heading.heading-medium{
.heading.heading-medium{
line-height: 2rem;
font: var(--goa-typography-heading-m);
}


@media (--mobile) {
summary {
align-items: flex-start;
}
summary .title {
flex-direction: column;
align-items: flex-start;
padding-bottom: 0.875rem;
}
summary .title span {
padding-bottom: 0;
}
summary .heading-content.heading-content-top {
margin-top: var(--goa-space-xs);
}
}

</style>
3 changes: 2 additions & 1 deletion libs/web-components/src/components/button/Button.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@
box-sizing: border-box;
font-family: var(--goa-font-family-sans);
}
@media (--mobile) {

@container (--mobile) {
/* expand the button and :host container on small screens */
:host {
width: 100%;
Expand Down
Loading
Loading