Skip to content

Commit

Permalink
Fix underscore properties
Browse files Browse the repository at this point in the history
  • Loading branch information
ghivert committed Jan 11, 2025
1 parent 538f2b6 commit eb27f26
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ title: erlang_css_function_css.gleam
}

.sketch_css_test-classes-function_css_property {
width-: 12px;
width: 12px;
color: blue;
color: var(--custom);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: 1.2.5
title: js_css_function_css.gleam
---
.sketch_css_test-classes-function_css_property {
width-: 12px;
width: 12px;
color: blue;
color: var(--custom);
}
Expand Down
5 changes: 4 additions & 1 deletion sketch_css/src/sketch_css/module/stylesheet.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,10 @@ fn convert_generic_call(
Ok(c), _ -> convert_pseudo_selector_call(label, c, arguments, env, modules)
_, Ok(c) -> convert_combinator_call(c, arguments, env, modules)
_, _ -> {
let label = string.replace(label, each: "_", with: "-")
let label =
label
|> utils.remove_trailing_underscore
|> string.replace(each: "_", with: "-")
case arguments {
[g.UnlabelledField(item: g.List(styles, ..))] -> {
let styles = list.try_map(styles, convert_expression(_, env, modules))
Expand Down
9 changes: 9 additions & 0 deletions sketch_css/src/sketch_css/utils.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@ pub fn outputs(directories: Directories, name: String) -> Outputs {
Outputs(dst:, interface:, dst_file:, interface_file:)
}

pub fn remove_trailing_underscore(label: String) {
case string.ends_with(label, "_") {
False -> label
True ->
string.drop_end(label, 1)
|> remove_trailing_underscore
}
}

fn read_directory(
key: String,
flag: Option(String),
Expand Down

0 comments on commit eb27f26

Please sign in to comment.