Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Simplify breakpointOverwrites map
  • Loading branch information
philipp-spiess committed Nov 14, 2024
commit 2d1a43281ebf13b0a654ebda767bfc56764a2483
16 changes: 8 additions & 8 deletions packages/tailwindcss/src/compat/container.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { atRule, decl, type AstNode } from '../ast'
import { atRule, decl, type AstNode, type AtRule } from '../ast'
import type { DesignSystem } from '../design-system'
import { compareBreakpoints } from '../utils/compare-breakpoints'
import type { ResolvedConfig } from './config/types'
Expand Down Expand Up @@ -32,7 +32,7 @@ export function buildCustomContainerUtilityRules(
designSystem: DesignSystem,
): AstNode[] {
let rules = []
let breakpointOverwrites: null | Map<string, { nodes: AstNode[]; rule: string }> = null
let breakpointOverwrites: null | Map<string, AtRule> = null

if (center) {
rules.push(decl('margin-inline', 'auto'))
Expand Down Expand Up @@ -76,10 +76,10 @@ export function buildCustomContainerUtilityRules(
// We're inlining the breakpoint values because the screens configured in
// the `container` option do not have to match the ones defined in the
// root `screen` setting.
breakpointOverwrites.set(key, {
rule: `(width >= ${value})`,
nodes: [decl('max-width', value)],
})
breakpointOverwrites.set(
key,
atRule('@media', `(width >= ${value})`, [decl('max-width', value)]),
)
}
}

Expand Down Expand Up @@ -111,8 +111,8 @@ export function buildCustomContainerUtilityRules(
}

if (breakpointOverwrites) {
for (let [, { rule, nodes }] of breakpointOverwrites) {
if (nodes.length > 0) rules.push(atRule('@media', rule, nodes))
for (let [, rule] of breakpointOverwrites) {
rules.push(rule)
}
}

Expand Down