Skip to content

Commit

Permalink
Support no transformation
Browse files Browse the repository at this point in the history
  • Loading branch information
craigfay committed May 26, 2022
1 parent ca367d0 commit f1fa9fb
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 39 deletions.
54 changes: 27 additions & 27 deletions distill/atomic-design-tokens.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
spacings:
'1': 0.25rem
'2': 0.5rem
'3': 0.75rem
'4': 1rem
'5': 1.25rem
'6': 1.5rem
'7': 1.75rem
'8': 2rem
'9': 2.25rem
'10': 2.5rem
'11': 2.75rem
'12': 3rem
'14': 3.5rem
'16': 4rem
'20': 5rem
'24': 6rem
'28': 7rem
'32': 8rem
'36': 9rem
'40': 10rem
'52': 13rem
'56': 14rem
'60': 15rem
'64': 16rem
'72': 18rem
'80': 20rem
'96': 24rem
's1': 0.25rem
's2': 0.5rem
's3': 0.75rem
's4': 1rem
's5': 1.25rem
's6': 1.5rem
's7': 1.75rem
's8': 2rem
's9': 2.25rem
's10': 2.5rem
's11': 2.75rem
's12': 3rem
's14': 3.5rem
's16': 4rem
's20': 5rem
's24': 6rem
's28': 7rem
's32': 8rem
's36': 9rem
's40': 10rem
's52': 13rem
's56': 14rem
's60': 15rem
's64': 16rem
's72': 18rem
's80': 20rem
's96': 24rem
colors:
gray0: '#f8f9fa'
gray1: '#f1f3f5'
Expand Down
13 changes: 13 additions & 0 deletions distill/atomic-styles.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@

# Flexbox
flex:
display: flex

flex-wrap:
flex-wrap: wrap

flex-wrap-reverse:
flex-wrap: wrap-reverse

flex-no-wrap:
flex-wrap: nowrap

# Background Colors
bg-[$colors.key]:
background-color: var(--$colors.key)
Expand Down
20 changes: 10 additions & 10 deletions distill/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,24 @@ pub enum Transformation {
#[derive(Deserialize, Serialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct NoTransformation {
id: String,
description: String,
pub id: String,
pub description: String,
#[serde(rename = "@identifier")]
at_rule_identifier: Option<String>,
rules: Vec<CSSRule>,
pub at_rule_identifier: Option<String>,
pub rules: Vec<CSSRule>,
}



#[derive(Deserialize, Serialize,Debug)]
#[derive(Deserialize, Serialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct CopyExistingRules{
id: String,
description: String,
affected_ids: Vec<String>,
pub id: String,
pub description: String,
pub affected_ids: Vec<String>,
#[serde(rename = "@identifier")]
at_rule_identifier: Option<String>,
new_selector: String,
pub at_rule_identifier: Option<String>,
pub new_selector: String,
}


Expand Down
1 change: 1 addition & 0 deletions distill/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ fn main() {
};
}


fn write_file_creating_dirs(path: &str, contents: &str) {
let path = Path::new(path);
let parent_dir = path.clone().parent().unwrap();
Expand Down
27 changes: 25 additions & 2 deletions distill/src/sugar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use super::lib::{
Transformation,
Transformations,
ManyRulesFromTokenGroup,
NoTransformation,
CSSRule,
};

Expand All @@ -30,7 +31,6 @@ m-[$sizes.key]:
"#;

type AtomName = String;
type TokenGroupName = String;
type CSSProperty = String;
type CSSValue = String;

Expand All @@ -42,9 +42,32 @@ pub fn transformations_from_sugar_rules(ruleset: &SugarRuleSet) -> Transformatio

for (atom_name_template, block) in ruleset {
match detect_token_loop(atom_name_template, block) {
Some(config) => list.push(Transformation::ManyRulesFromTokenGroup(config)),
None => (),
Some(config) => {
list.push(Transformation::ManyRulesFromTokenGroup(config));
continue;
}
}

// Assuming no transformation is required

let mut rule = CSSRule {
selector: get_atom_selector(atom_name_template),
declarations: BTreeMap::new(),
};

for (property, value) in block {
rule.declarations.insert(property.to_string(), value.to_string());
}

let config = NoTransformation {
id: atom_name_template.to_string(),
description: "".to_string(),
at_rule_identifier: None,
rules: vec![rule],
};

list.push(Transformation::NoTransformation(config));
}

list
Expand Down

0 comments on commit f1fa9fb

Please sign in to comment.