Home / File/ screens-config.ts — tailwindcss Source File

screens-config.ts — tailwindcss Source File

Architecture documentation for screens-config.ts, a typescript file in the tailwindcss codebase. 4 imports, 2 dependents.

File typescript OxideEngine Scanner 4 imports 2 dependents 2 functions

Entity Profile

Dependency Diagram

graph LR
  09dea224_4143_d043_b336_121f3fdb8f12["screens-config.ts"]
  42640952_ea63_55f1_1ff1_00816e2980ae["ast.ts"]
  09dea224_4143_d043_b336_121f3fdb8f12 --> 42640952_ea63_55f1_1ff1_00816e2980ae
  f9b19679_c1f0_28d6_4d1a_31a10c52e42d["atRule"]
  09dea224_4143_d043_b336_121f3fdb8f12 --> f9b19679_c1f0_28d6_4d1a_31a10c52e42d
  7fd72d4c_e95c_d849_1002_1e1c9d8aca1a["design-system.ts"]
  09dea224_4143_d043_b336_121f3fdb8f12 --> 7fd72d4c_e95c_d849_1002_1e1c9d8aca1a
  c1272aed_91bb_73df_0746_d55fa9b302fd["types.ts"]
  09dea224_4143_d043_b336_121f3fdb8f12 --> c1272aed_91bb_73df_0746_d55fa9b302fd
  b1548999_24c2_f98a_628a_e4dd9606794b["migrate-media-screen.ts"]
  b1548999_24c2_f98a_628a_e4dd9606794b --> 09dea224_4143_d043_b336_121f3fdb8f12
  daaadd53_16ee_21c6_12d9_8feaac80a91b["apply-compat-hooks.ts"]
  daaadd53_16ee_21c6_12d9_8feaac80a91b --> 09dea224_4143_d043_b336_121f3fdb8f12
  style 09dea224_4143_d043_b336_121f3fdb8f12 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { atRule } from '../ast'
import type { DesignSystem } from '../design-system'
import type { ResolvedConfig } from './config/types'

export function registerScreensConfig(userConfig: ResolvedConfig, designSystem: DesignSystem) {
  let screens = userConfig.theme.screens || {}

  // We want to insert the breakpoints in the right order as best we can. In the
  // core utility, all static breakpoint variants and the `min-*` functional
  // variant are registered inside a group. Since all the variants within a
  // group share the same order, we can use the always-defined `min-*` variant
  // as the order.
  let coreOrder = designSystem.variants.get('min')?.order ?? 0

  let additionalVariants: ((order: number) => void)[] = []

  // Register static breakpoint variants for everything that comes from the user
  // theme config.
  for (let [name, value] of Object.entries(screens)) {
    let coreVariant = designSystem.variants.get(name)

    // Ignore it if there's a CSS value that takes precedence over the JS config
    // and the static utilities are already registered.
    //
    // This happens when a `@theme { }` block is used that overwrites all JS
    // config options. We rely on the resolution order of the Theme for
    // resolving this. If Theme has a different value, we know that this is not
    // coming from the JS plugin and thus we don't need to handle it explicitly.
    let cssValue = designSystem.theme.resolveValue(name, ['--breakpoint'])
    if (coreVariant && cssValue && !designSystem.theme.hasDefault(`--breakpoint-${name}`)) {
      continue
    }

    let deferInsert = true

    if (typeof value === 'string') {
      deferInsert = false
    }

    let query = buildMediaQuery(value)

    function insert(order: number) {
      // `min-*` and `max-*` rules do not need to be reconfigured, as they are
      // reading the latest values from the theme.
      designSystem.variants.static(
        name,
        (ruleNode) => {
          ruleNode.nodes = [atRule('@media', query, ruleNode.nodes)]
        },
        { order },
      )
    }

    if (deferInsert) {
      additionalVariants.push(insert)
    } else {
      insert(coreOrder)
    }
  }

// ... (64 more lines)

Domain

Subdomains

Frequently Asked Questions

What does screens-config.ts do?
screens-config.ts is a source file in the tailwindcss codebase, written in typescript. It belongs to the OxideEngine domain, Scanner subdomain.
What functions are defined in screens-config.ts?
screens-config.ts defines 2 function(s): buildMediaQuery, registerScreensConfig.
What does screens-config.ts depend on?
screens-config.ts imports 4 module(s): ast.ts, atRule, design-system.ts, types.ts.
What files import screens-config.ts?
screens-config.ts is imported by 2 file(s): apply-compat-hooks.ts, migrate-media-screen.ts.
Where is screens-config.ts in the architecture?
screens-config.ts is located at packages/tailwindcss/src/compat/screens-config.ts (domain: OxideEngine, subdomain: Scanner, directory: packages/tailwindcss/src/compat).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free