Skip to content

Commit

Permalink
Increasing specificity
Browse files Browse the repository at this point in the history
  • Loading branch information
ackava committed Feb 1, 2024
1 parent 8d497d9 commit 2342c3e
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
9 changes: 7 additions & 2 deletions src/styled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,14 @@ export type IStyleFragmentSet = {
}

const styles: IStyleFragmentSet[] = [];
const lowestStyles: IStyleFragmentSet[] = [];
const lowStyles: IStyleFragmentSet[] = [];
const highStyles: IStyleFragmentSet[] = [];

const styled = {

get styles() {
return [... lowStyles, ... styles, ... highStyles];
return [ ... lowestStyles, ... lowStyles, ... styles, ... highStyles];
},

css: (t: TemplateStringsArray, ... a: any[]) => {
Expand All @@ -156,7 +157,11 @@ const styled = {
return StyleFragment.newStyle( { content: r });
},

add(x: IStyleFragmentSet, priority: "high" | "normal" | "low" = "normal") {
add(x: IStyleFragmentSet, priority: "high" | "normal" | "low" | "lowest" = "normal") {
if (priority === "lowest") {
lowestStyles.push(x);
return;
}
if (priority === "low") {
lowStyles.push(x);
return;
Expand Down
26 changes: 26 additions & 0 deletions src/styles/data-buttons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,32 @@ const createButton = (
};
};

const createButtonDisplay = (
{
name,
}: { name: string }) => {

return {
[name + "icon-button"]: styled.css `
display: flex;
align-items: center;
justify-content: center;
`,
};
};

styled.add({
"button[data-layout]": {
... createButtonDisplay({ name: ""}),
... createButtonDisplay({ name: "accent-"}),
... createButtonDisplay({ name: "stop-"}),
... createButtonDisplay({ name: "go-"}),
... createButtonDisplay({ name: "accept-"}),
... createButtonDisplay({ name: "warning-"}),
... createButtonDisplay({ name: "reject-"}),
}
}, "lowest");

styled.add({

"data-layout": {
Expand Down
2 changes: 1 addition & 1 deletion src/styles/layouts/data-grid/data-grid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ styled.add({
padding: ${vars.spacing};
& > *, & > button {
& > *, & > button, & > button {
padding: ${vars.spacing};
display: table-cell;
vertical-align: top;
Expand Down

0 comments on commit 2342c3e

Please sign in to comment.