Skip to content

Commit

Permalink
nit
Browse files Browse the repository at this point in the history
  • Loading branch information
CarelessCourage committed Dec 30, 2023
1 parent a256219 commit d5ab910
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/core/engine/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function umbraAdjust(settings: UmbraSettings, scheme = defaultScheme) {

export function umbraHydrate(input: UmbraInput, output: RawRange[]) {
const apply = ({ element, formater, alias }: ApplyProps = {}) =>
format({ output, formater }).attach(element, alias)
format({ output, formater }).attach(input, element, alias)
return {
apply,
input,
Expand Down
6 changes: 4 additions & 2 deletions packages/core/engine/primitives/attach.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { UmbraInput } from '../..'
import { FlattenColor, UmbraOutputs } from './format'

//Why aliases? 2 reasons:
Expand Down Expand Up @@ -62,17 +63,18 @@ const defaultAliases = {
// }

interface Attach {
input: UmbraInput
outputs: UmbraOutputs
element?: HTMLElement | null
alias?: Alias | boolean
}

//main
export function attach({ outputs, element, alias }: Attach) {
export function attach({ input, outputs, element, alias }: Attach) {
if (!document) return outputs

setColors(outputs.flattened, element)
setAliases(alias || outputs.output.input.settings.aliases, element)
setAliases(alias || input.settings.aliases, element)

if (!element) return outputs
//Ensure that the foreground color is always set to the attached element
Expand Down
6 changes: 3 additions & 3 deletions packages/core/engine/primitives/format.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Colord } from 'colord'
import { umbra } from '../..'
import { RawRange, FormatedRange } from '../types'
import { RawRange, FormatedRange, UmbraInput } from '../types'
import { attach, Alias } from './attach'

export type Formater = (color: Colord) => string
Expand All @@ -12,7 +12,7 @@ interface FormatProps {
}

export interface Format extends UmbraOutputs {
attach: (element?: HTMLElement, alias?: Alias | boolean) => UmbraOutputs
attach: (input: UmbraInput, element?: HTMLElement, alias?: Alias | boolean) => UmbraOutputs
}

export interface UmbraOutputs {
Expand Down Expand Up @@ -52,7 +52,7 @@ export const format = ({ output = umbra().output, formater = defaultFormater }:
}

return {
attach: (element, alias) => attach({ outputs, element, alias }),
attach: (input, element, alias) => attach({ input, outputs, element, alias }),
...outputs
} as Format
}
Expand Down

0 comments on commit d5ab910

Please sign in to comment.