Skip to content

Commit 334b966

Browse files
committed
cleanup to reuse default blockly styles where it makes sense
1 parent b258d95 commit 334b966

File tree

1 file changed

+22
-31
lines changed

1 file changed

+22
-31
lines changed

src/themes/styles.ts

Lines changed: 22 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -36,48 +36,31 @@ export const MRC_STYLE_EVENT_HANDLER = 'mrc_style_event_handler';
3636
export const MRC_CATEGORY_STYLE_COMPONENTS = 'mrc_category_style_components';
3737

3838
export const add_mrc_styles = function (theme: Blockly.Theme): Blockly.Theme {
39+
const procedureStyle = theme.blockStyles['procedure_blocks'];
40+
const variableStyle = theme.blockStyles['variable_blocks'];
41+
3942
theme.setBlockStyle(MRC_STYLE_FUNCTIONS, {
40-
colourPrimary: "#805ba5",
41-
colourSecondary: "#e6deed",
42-
colourTertiary: "#664984",
43-
hat: ""
43+
...procedureStyle
4444
});
4545
theme.setBlockStyle(MRC_STYLE_EVENT_HANDLER, {
46-
colourPrimary: "#805ba5",
47-
colourSecondary: "#e6deed",
48-
colourTertiary: "#664984",
46+
...procedureStyle,
4947
hat: "cap"
5048
});
5149
theme.setBlockStyle(MRC_STYLE_EVENTS, {
52-
colourPrimary: "#805ba5",
53-
colourSecondary: "#e6deed",
54-
colourTertiary: "#664984",
55-
hat: ""
50+
...procedureStyle
5651
});
5752
theme.setBlockStyle(MRC_STYLE_ENUM, {
58-
colourPrimary: "#5ba5a5",
59-
colourSecondary: "#deeded",
60-
colourTertiary: "#498484",
61-
hat: ""
53+
...variableStyle
6254
});
6355
theme.setBlockStyle(MRC_STYLE_VARIABLES, {
64-
colourPrimary: "#5ba55b",
65-
colourSecondary: "#deedde",
66-
colourTertiary: "#498449",
67-
hat: ""
56+
...variableStyle
6857
});
6958
theme.setBlockStyle(MRC_STYLE_CLASS_BLOCKS, {
7059
colourPrimary: "#4a148c",
7160
colourSecondary: "#AD7BE9",
7261
colourTertiary: "#CDB6E9",
7362
hat: ""
7463
});
75-
theme.setCategoryStyle(MRC_CATEGORY_STYLE_METHODS, {
76-
colour: '#4A148C',
77-
});
78-
theme.setCategoryStyle(MRC_CATEGORY_STYLE_COMPONENTS, {
79-
colour: '#4A148C',
80-
});
8164

8265
theme.setBlockStyle(MRC_STYLE_COMMENTS, {
8366
colourPrimary: "#5b5ba5",
@@ -92,16 +75,16 @@ export const add_mrc_styles = function (theme: Blockly.Theme): Blockly.Theme {
9275
hat: ""
9376
});
9477
theme.setBlockStyle(MRC_STYLE_MECHANISMS, {
95-
"colourPrimary": "#5b61a5",
96-
"colourSecondary": "#dedfed",
97-
"colourTertiary": "#494e84",
78+
colourPrimary: "#5b61a5",
79+
colourSecondary: "#dedfed",
80+
colourTertiary: "#494e84",
9881
hat: ""
9982

10083
});
10184
theme.setBlockStyle(MRC_STYLE_COMPONENTS, {
102-
"colourPrimary": "#5b80a5",
103-
"colourSecondary": "#dee6ed",
104-
"colourTertiary": "#496684",
85+
colourPrimary: "#5b80a5",
86+
colourSecondary: "#dee6ed",
87+
colourTertiary: "#496684",
10588
hat: ""
10689
});
10790
theme.setBlockStyle(MRC_STYLE_PORTS, {
@@ -110,6 +93,14 @@ export const add_mrc_styles = function (theme: Blockly.Theme): Blockly.Theme {
11093
colourTertiary: "#498449",
11194
hat: ""
11295
});
96+
const functionCategoryStyle = theme.categoryStyles['procedure_category'];
97+
98+
theme.setCategoryStyle(MRC_CATEGORY_STYLE_METHODS, {
99+
...functionCategoryStyle,
100+
});
101+
theme.setCategoryStyle(MRC_CATEGORY_STYLE_COMPONENTS, {
102+
colour: '#4A148C',
103+
});
113104

114105
return theme;
115106
}

0 commit comments

Comments
 (0)