Skip to content

Commit

Permalink
chore: optimize devsite's toolbox css config and localized names inje…
Browse files Browse the repository at this point in the history
…ction (google#2312)

* feat: use css config in devsite toolbox

* feat: rename `functions` with `procedures` to correspond to msgs keys

* feat: optimize localized string filling approach in devsite

* feat: remove colour block style of devsite

* chore(format): format with prettier

* chore(format): format another file to pass check
  • Loading branch information
mobyw authored and gonfunko committed Apr 15, 2024
1 parent 6e581a5 commit 0c314ec
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 23 deletions.
16 changes: 3 additions & 13 deletions examples/devsite-landing-demo/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,9 @@ function init() {
}

// Inject localized category names.
toolboxJson['contents'][0].name = getMsg('Logic');
toolboxJson['contents'][1].name = getMsg('Loops');
toolboxJson['contents'][2].name = getMsg('Math');
toolboxJson['contents'][3].name = getMsg('Text');
toolboxJson['contents'][4].name = getMsg('Lists');
// Separator.
toolboxJson['contents'][6].name = getMsg('Variables');
toolboxJson['contents'][7].name = getMsg('Procedures');
toolboxJson['contents'].forEach(function (part) {
part.name = getMsg(part.name);
});

// Inject default variable name.
// https://github.com/google/blockly/issues/5238
Expand Down Expand Up @@ -138,11 +133,6 @@ function init() {
colourSecondary: '#B2DFDB',
colorTertiary: '#009688',
},
colour_blocks: {
colourPrimary: '#FFCDD2',
colourSecondary: '#FFEBEE',
colorTertiary: '#EF9A9A',
},
variable_blocks: {
colourPrimary: '#EF9A9A',
colourSecondary: '#FFEBEE',
Expand Down
14 changes: 7 additions & 7 deletions examples/devsite-landing-demo/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -75,31 +75,31 @@ option {
font-family: var(--font-family) !important;
}

#blockly-0 {
.blocklyTreeRowLogic {
border-left: 15px solid #d1c4e9 !important;
}

#blockly-1 {
.blocklyTreeRowLoops {
border-left: 15px solid #a5d6a7 !important;
}

#blockly-2 {
.blocklyTreeRowMath {
border-left: 15px solid #4285f4 !important;
}

#blockly-3 {
.blocklyTreeRowText {
border-left: 15px solid #ffca28 !important;
}

#blockly-4 {
.blocklyTreeRowLists {
border-left: 15px solid #4db6ac !important;
}

#blockly-6 {
.blocklyTreeRowVariables {
border-left: 15px solid #ef9a9a !important;
}

#blockly-7 {
.blocklyTreeRowProcedures {
border-left: 15px solid #d7ccc8 !important;
}

Expand Down
32 changes: 30 additions & 2 deletions examples/devsite-landing-demo/toolbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ let toolboxJson = {
{
// Logic Category
kind: 'CATEGORY',
name: 'Logic',
colour: 262,
cssConfig: {
row: 'blocklyTreeRow blocklyTreeRowLogic',
},
contents: [
{
kind: 'BLOCK',
Expand Down Expand Up @@ -47,7 +51,11 @@ let toolboxJson = {
{
// Loops Category
kind: 'CATEGORY',
name: 'Loops',
colour: 122,
cssConfig: {
row: 'blocklyTreeRow blocklyTreeRowLoops',
},
contents: [
{
kind: 'BLOCK',
Expand Down Expand Up @@ -103,7 +111,11 @@ let toolboxJson = {
{
// Math Category
kind: 'CATEGORY',
name: 'Math',
colour: 206,
cssConfig: {
row: 'blocklyTreeRow blocklyTreeRowMath',
},
contents: [
{
kind: 'BLOCK',
Expand Down Expand Up @@ -272,7 +284,11 @@ let toolboxJson = {
{
// Text Category
kind: 'CATEGORY',
name: 'Text',
colour: 46,
cssConfig: {
row: 'blocklyTreeRow blocklyTreeRowText',
},
contents: [
{
kind: 'BLOCK',
Expand Down Expand Up @@ -478,7 +494,11 @@ let toolboxJson = {
{
// Lists Category
kind: 'CATEGORY',
name: 'Lists',
colour: 172,
cssConfig: {
row: 'blocklyTreeRow blocklyTreeRowLists',
},
contents: [
{
kind: 'BLOCK',
Expand Down Expand Up @@ -650,17 +670,25 @@ let toolboxJson = {
},

{
// Variable Category
// Variables Category
kind: 'CATEGORY',
custom: 'VARIABLE',
name: 'Variables',
colour: 4,
cssConfig: {
row: 'blocklyTreeRow blocklyTreeRowVariables',
},
},

{
// Function Category
// Procedures Category
kind: 'CATEGORY',
custom: 'PROCEDURE',
name: 'Procedures',
colour: 16,
cssConfig: {
row: 'blocklyTreeRow blocklyTreeRowProcedures',
},
},
],
};
2 changes: 1 addition & 1 deletion plugins/migration/test/rename.mocha.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ suite('Rename', function () {
'1.0.0': [
{
oldName: 'Blockly',
exports: {}
exports: {},
},
{
oldName: 'Blockly.moduleA',
Expand Down

0 comments on commit 0c314ec

Please sign in to comment.