pub struct ThemeDocument {
pub format_version: u32,
pub metadata: ThemeMetadata,
pub palette: Palette,
pub variants: BTreeMap<Appearance, Palette>,
pub design: DesignTokens,
}Expand description
A saved theme, portable as JSON and independent of a specific app.
Fields§
§format_version: u32§metadata: ThemeMetadata§palette: PaletteThe established CYBERGRID color roles. New design properties are additive so older Cybercore consumers can still use this palette.
variants: BTreeMap<Appearance, Palette>§design: DesignTokensImplementations§
Source§impl ThemeDocument
impl ThemeDocument
pub fn new( id: impl Into<String>, name: impl Into<String>, palette: Palette, ) -> ThemeDocument
Sourcepub fn from_json(
input: &str,
legacy_id: &str,
) -> Result<ThemeDocument, ThemeError>
pub fn from_json( input: &str, legacy_id: &str, ) -> Result<ThemeDocument, ThemeError>
Read a current document or a legacy flat 11-color Cybercore palette. Legacy import needs an ID because the old file shape had none.
pub fn validate(&self) -> Result<(), ThemeError>
Sourcepub fn palette_for(&self, appearance: Appearance) -> &Palette
pub fn palette_for(&self, appearance: Appearance) -> &Palette
Resolve the requested appearance, falling back to the base palette.
Sourcepub fn contrast_report(&self, appearance: Appearance) -> ContrastReport
pub fn contrast_report(&self, appearance: Appearance) -> ContrastReport
Build a contrast report for text and accent colors on common surfaces.
Sourcepub fn quality_report(&self) -> ThemeQualityReport
pub fn quality_report(&self) -> ThemeQualityReport
Run contrast checks for both modes and report whether the light palette was explicitly designed instead of using the compatibility fallback.
Sourcepub fn to_css(&self, appearance: Appearance) -> String
pub fn to_css(&self, appearance: Appearance) -> String
CSS variables understood by the existing Cybercore apps plus shared typography, density, corner, and motion tokens.
Trait Implementations§
Source§impl Clone for ThemeDocument
impl Clone for ThemeDocument
Source§fn clone(&self) -> ThemeDocument
fn clone(&self) -> ThemeDocument
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ThemeDocument
impl Debug for ThemeDocument
Source§impl<'de> Deserialize<'de> for ThemeDocument
impl<'de> Deserialize<'de> for ThemeDocument
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<ThemeDocument, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<ThemeDocument, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for ThemeDocument
Source§impl PartialEq for ThemeDocument
impl PartialEq for ThemeDocument
Source§impl Serialize for ThemeDocument
impl Serialize for ThemeDocument
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl StructuralPartialEq for ThemeDocument
Auto Trait Implementations§
impl Freeze for ThemeDocument
impl RefUnwindSafe for ThemeDocument
impl Send for ThemeDocument
impl Sync for ThemeDocument
impl Unpin for ThemeDocument
impl UnsafeUnpin for ThemeDocument
impl UnwindSafe for ThemeDocument
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more