fix: move density to cosmic_theme
This commit is contained in:
parent
69e6fb63fb
commit
0a34660a80
6 changed files with 85 additions and 71 deletions
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
//! Configurations available to libcosmic applications.
|
||||
|
||||
use crate::cosmic_theme::Spacing;
|
||||
use crate::cosmic_theme::Density;
|
||||
use cosmic_config::cosmic_config_derive::CosmicConfigEntry;
|
||||
use cosmic_config::{Config, CosmicConfigEntry};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
|
@ -85,69 +85,6 @@ pub struct CosmicTk {
|
|||
pub interface_density: Density,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize)]
|
||||
pub enum Density {
|
||||
Compact,
|
||||
Spacious,
|
||||
#[default]
|
||||
Standard,
|
||||
}
|
||||
|
||||
impl From<Density> for Spacing {
|
||||
fn from(value: Density) -> Self {
|
||||
match value {
|
||||
Density::Compact => Spacing {
|
||||
space_none: 0,
|
||||
space_xxxs: 4,
|
||||
space_xxs: 4,
|
||||
space_xs: 8,
|
||||
space_s: 8,
|
||||
space_m: 16,
|
||||
space_l: 24,
|
||||
space_xl: 32,
|
||||
space_xxl: 48,
|
||||
space_xxxl: 64,
|
||||
},
|
||||
Density::Spacious => Spacing {
|
||||
space_none: 4,
|
||||
space_xxxs: 8,
|
||||
space_xxs: 12,
|
||||
space_xs: 16,
|
||||
space_s: 24,
|
||||
space_m: 32,
|
||||
space_l: 48,
|
||||
space_xl: 64,
|
||||
space_xxl: 128,
|
||||
space_xxxl: 160,
|
||||
},
|
||||
Density::Standard => Spacing {
|
||||
space_none: 0,
|
||||
space_xxxs: 4,
|
||||
space_xxs: 8,
|
||||
space_xs: 12,
|
||||
space_s: 16,
|
||||
space_m: 24,
|
||||
space_l: 32,
|
||||
space_xl: 48,
|
||||
space_xxl: 64,
|
||||
space_xxxl: 128,
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Spacing> for Density {
|
||||
fn from(value: Spacing) -> Self {
|
||||
if (value.space_m - 16) < 1 {
|
||||
Self::Compact
|
||||
} else if (value.space_m - 24) < 1 {
|
||||
Self::Standard
|
||||
} else {
|
||||
Self::Spacious
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for CosmicTk {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue