-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expose stylesheet model API publicly (#12688)
- Loading branch information
Showing
16 changed files
with
315 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
import {Model} from "../../model" | ||
import * as dom from "core/dom" | ||
import * as p from "core/properties" | ||
|
||
export namespace StyleSheet { | ||
export type Attrs = p.AttrsOf<Props> | ||
export type Props = Model.Props | ||
} | ||
|
||
export interface StyleSheet extends StyleSheet.Attrs {} | ||
|
||
export abstract class StyleSheet extends Model { | ||
override properties: StyleSheet.Props | ||
|
||
constructor(attrs?: Partial<StyleSheet.Attrs>) { | ||
super(attrs) | ||
} | ||
|
||
abstract underlying(): dom.StyleSheet | ||
} | ||
|
||
export namespace InlineStyleSheet { | ||
export type Attrs = p.AttrsOf<Props> | ||
export type Props = StyleSheet.Props & { | ||
css: p.Property<string> | ||
} | ||
} | ||
|
||
export interface InlineStyleSheet extends InlineStyleSheet.Attrs {} | ||
|
||
export class InlineStyleSheet extends StyleSheet { | ||
override properties: InlineStyleSheet.Props | ||
|
||
constructor(attrs?: Partial<InlineStyleSheet.Attrs>) { | ||
super(attrs) | ||
} | ||
|
||
static { | ||
this.define<InlineStyleSheet.Props>(({String}) => ({ | ||
css: [ String ], | ||
})) | ||
} | ||
|
||
underlying(): dom.StyleSheet { | ||
return new dom.InlineStyleSheet(this.css) | ||
} | ||
} | ||
|
||
export namespace ImportedStyleSheet { | ||
export type Attrs = p.AttrsOf<Props> | ||
export type Props = StyleSheet.Props & { | ||
url: p.Property<string> | ||
} | ||
} | ||
|
||
export interface ImportedStyleSheet extends ImportedStyleSheet.Attrs {} | ||
|
||
export class ImportedStyleSheet extends StyleSheet { | ||
override properties: ImportedStyleSheet.Props | ||
|
||
constructor(attrs?: Partial<ImportedStyleSheet.Attrs>) { | ||
super(attrs) | ||
} | ||
|
||
static { | ||
this.define<ImportedStyleSheet.Props>(({String}) => ({ | ||
url: [ String ], | ||
})) | ||
} | ||
|
||
underlying(): dom.StyleSheet { | ||
return new dom.ImportedStyleSheet(this.url) | ||
} | ||
} | ||
|
||
export namespace GlobalInlineStyleSheet { | ||
export type Attrs = p.AttrsOf<Props> | ||
export type Props = InlineStyleSheet.Props | ||
} | ||
|
||
export interface GlobalInlineStyleSheet extends GlobalInlineStyleSheet.Attrs {} | ||
|
||
export class GlobalInlineStyleSheet extends InlineStyleSheet { | ||
override properties: GlobalInlineStyleSheet.Props | ||
|
||
constructor(attrs?: Partial<GlobalInlineStyleSheet.Attrs>) { | ||
super(attrs) | ||
} | ||
|
||
private _underlying: dom.StyleSheet | null = null | ||
|
||
override underlying(): dom.StyleSheet { | ||
if (this._underlying == null) | ||
this._underlying = new dom.GlobalInlineStyleSheet(this.css) | ||
return this._underlying | ||
} | ||
} | ||
|
||
export namespace GlobalImportedStyleSheet { | ||
export type Attrs = p.AttrsOf<Props> | ||
export type Props = ImportedStyleSheet.Props | ||
} | ||
|
||
export interface GlobalImportedStyleSheet extends GlobalImportedStyleSheet.Attrs {} | ||
|
||
export class GlobalImportedStyleSheet extends ImportedStyleSheet { | ||
override properties: GlobalImportedStyleSheet.Props | ||
|
||
constructor(attrs?: Partial<GlobalImportedStyleSheet.Attrs>) { | ||
super(attrs) | ||
} | ||
|
||
private _underlying: dom.StyleSheet | null = null | ||
|
||
override underlying(): dom.StyleSheet { | ||
if (this._underlying == null) | ||
this._underlying = new dom.GlobalInlineStyleSheet(this.url) | ||
return this._underlying | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.