Home / File/ useCssVars.ts — vue Source File

useCssVars.ts — vue Source File

Architecture documentation for useCssVars.ts, a typescript file in the vue codebase. 3 imports, 0 dependents.

File typescript VueCore GlobalAPI 3 imports 1 functions

Entity Profile

Dependency Diagram

graph LR
  9c7497a9_d0ae_4161_5b72_874880676aaa["useCssVars.ts"]
  e6ff5abc_a994_a708_f419_135f684100a5["../"]
  9c7497a9_d0ae_4161_5b72_874880676aaa --> e6ff5abc_a994_a708_f419_135f684100a5
  9f3b1774_ebd5_0845_1a85_868e0c1fd480["currentInstance.ts"]
  9c7497a9_d0ae_4161_5b72_874880676aaa --> 9f3b1774_ebd5_0845_1a85_868e0c1fd480
  6d8f8976_7066_720b_0d45_45fe42921eaf["util"]
  9c7497a9_d0ae_4161_5b72_874880676aaa --> 6d8f8976_7066_720b_0d45_45fe42921eaf
  style 9c7497a9_d0ae_4161_5b72_874880676aaa fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { watchPostEffect } from '../'
import { inBrowser, warn } from 'core/util'
import { currentInstance } from '../currentInstance'

/**
 * Runtime helper for SFC's CSS variable injection feature.
 * @private
 */
export function useCssVars(
  getter: (
    vm: Record<string, any>,
    setupProxy: Record<string, any>
  ) => Record<string, string>
) {
  if (!inBrowser && !__TEST__) return

  const instance = currentInstance
  if (!instance) {
    __DEV__ &&
      warn(`useCssVars is called without current active component instance.`)
    return
  }

  watchPostEffect(() => {
    const el = instance.$el
    const vars = getter(instance, instance._setupProxy!)
    if (el && el.nodeType === 1) {
      const style = (el as HTMLElement).style
      for (const key in vars) {
        style.setProperty(`--${key}`, vars[key])
      }
    }
  })
}

Domain

Subdomains

Functions

Dependencies

Frequently Asked Questions

What does useCssVars.ts do?
useCssVars.ts is a source file in the vue codebase, written in typescript. It belongs to the VueCore domain, GlobalAPI subdomain.
What functions are defined in useCssVars.ts?
useCssVars.ts defines 1 function(s): useCssVars.
What does useCssVars.ts depend on?
useCssVars.ts imports 3 module(s): ../, currentInstance.ts, util.
Where is useCssVars.ts in the architecture?
useCssVars.ts is located at src/v3/sfc-helpers/useCssVars.ts (domain: VueCore, subdomain: GlobalAPI, directory: src/v3/sfc-helpers).

Analyze Your Own Codebase

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

Try Supermodel Free