Skip to content

Commit

Permalink
first
Browse files Browse the repository at this point in the history
  • Loading branch information
danielferro69 committed May 20, 2024
1 parent 63c468d commit 04c8fdb
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 68 deletions.
42 changes: 21 additions & 21 deletions src/components/blockly/PBBlocklyWorkspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,29 @@ export type PBBlocklyWorkspaceProps = {
title?: boolean
} & Partial<BlocklyWorkspaceProps>

export const PBBlocklyWorkspace = ({blockIds, categorized, sx, title, ...props}: PBBlocklyWorkspaceProps) => {
const {t} = useTranslation("blocks")
export const PBBlocklyWorkspace = ({ blockIds, categorized, sx, title, ...props }: PBBlocklyWorkspaceProps) => {
const { t } = useTranslation("blocks")

const blocksWithCategories: BlockType[] = blockIds.map(getBlockFromId)

setupBlocklyBlocks(t)

return <PBCard sx={{...sx}}>
{title && <Typography>{t('preview')}</Typography>}
<BlocklyWorkspace
data-testid={blockIds.join(",")}
key={blockIds.join("") + categorized} //rerenders on toolbox or categorization changes
toolboxConfiguration={categorized ? categorizedToolbox(t, blocksWithCategories) : uncategorizedToolbox(blocksWithCategories)}
workspaceConfiguration={{}}
onWorkspaceChange={()=>{}}
onImportXmlError={()=>{}}
onImportError={()=>{}}
onXmlChange={()=>{}}
onJsonChange={()=>{}}
onInject={()=>{}}
onDispose={()=>{}}
className={styles.fill}
{...props}
/>
</PBCard>
return <PBCard sx={{ ...sx, ".blocklyToolboxContents": { flexWrap: "noWrap", }}}>
{title && <Typography>{t('preview')}</Typography>}
<BlocklyWorkspace
data-testid={blockIds.join(",")}
key={blockIds.join("") + categorized} //rerenders on toolbox or categorization changes
toolboxConfiguration={categorized ? categorizedToolbox(t, blocksWithCategories) : uncategorizedToolbox(blocksWithCategories)}
workspaceConfiguration={{}}
onWorkspaceChange={() => { }}
onImportXmlError={() => { }}
onImportError={() => { }}
onXmlChange={() => { }}
onJsonChange={() => { }}
onInject={() => { }}
onDispose={() => { }}
className={styles.fill}
{...props}
/>
</PBCard>
}
5 changes: 0 additions & 5 deletions src/components/blockly/blockly.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1443,11 +1443,6 @@ export const categorizedToolbox = (t: (key: string) => string, blocks: BlockType
name: `${t('categories.alternatives')}`,
contents: blocks.filter(block => block.categoryId === "alternatives").map(blockTypeToToolboxBlock)
},
{
kind: "category",
name: `${t('categories.variables')}`,
contents: blocks.filter(block => block.categoryId === "variables").map(blockTypeToToolboxBlock)
},
{
kind: "category",
name: `${t('categories.values')}`,
Expand Down
85 changes: 43 additions & 42 deletions src/components/blockly/blocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export const categories: string[] = [
'alternatives',
'values',
'sensors',
'variables',
'operators'
]

Expand Down Expand Up @@ -138,11 +137,6 @@ export const commonBlocks: BlockType[] = [
intlId: 'Procedures',
categoryId: 'myprocedures'
},
{
id: 'Avanzar',
intlId: 'advance',
categoryId: 'primitives'
},
{
id: 'PuedeMoverAbajo',
intlId: 'canMoveDown',
Expand All @@ -153,7 +147,49 @@ export const commonBlocks: BlockType[] = [
intlId: 'canMoveRight',
categoryId: 'sensors'
},
{
id: 'SiguienteColumna',
intlId: 'nextColumn',
categoryId: 'primitives'
},
{
id: 'SiguienteFila',
intlId: 'nextLine',
categoryId: 'primitives'
},
{
id: 'TocandoInicio',
intlId: 'atTheBeginning',
categoryId: 'sensors'
},
{
id: 'VolverABordeIzquierdo',
intlId: 'goToLeftBorder',
categoryId: 'primitives'
},
{
id: 'VolverAlBordeIzquierdo',
intlId: 'backToLeftBorder',
categoryId: 'primitives'
},
{
id: 'RepetirVacio',
intlId: 'repeatEmpty',
categoryId: 'repetitions'
},
{
id: 'Retroceder',
intlId: 'back',
categoryId: 'primitives'
}
]

const notUsedBlocks: BlockType[] = [
{
id: 'Avanzar',
intlId: 'advance',
categoryId: 'primitives'
},
{
id: 'EscribirA',
intlId: 'writeA',
Expand All @@ -179,11 +215,6 @@ export const commonBlocks: BlockType[] = [
intlId: 'atTheSquare',
categoryId: 'sensors'
},
{
id: 'Retroceder',
intlId: 'back',
categoryId: 'primitives'
},
{
id: 'SaltarAbajo',
intlId: 'jumpDown',
Expand All @@ -204,41 +235,11 @@ export const commonBlocks: BlockType[] = [
intlId: 'jumpLeft',
categoryId: 'primitives'
},
{
id: 'SiguienteColumna',
intlId: 'nextColumn',
categoryId: 'primitives'
},
{
id: 'SiguienteFila',
intlId: 'nextLine',
categoryId: 'primitives'
},
{
id: 'SiguienteFilaTotal',
intlId: 'nextLine',
categoryId: 'primitives'
},
{
id: 'TocandoInicio',
intlId: 'atTheBeginning',
categoryId: 'sensors'
},
{
id: 'VolverABordeIzquierdo',
intlId: 'goToLeftBorder',
categoryId: 'primitives'
},
{
id: 'VolverAlBordeIzquierdo',
intlId: 'backToLeftBorder',
categoryId: 'primitives'
},
{
id: 'RepetirVacio',
intlId: 'repeatEmpty',
categoryId: 'repetitions'
},
{
id: 'SaltarHaciaAdelante',
intlId: 'JumpForward',
Expand Down Expand Up @@ -639,7 +640,7 @@ export const sceneBlocks: BlockType[] = [
categoryId: 'primitives'
},
{
id: 'hayVocalRMT',
id: 'HayVocalRMT',
intlId: 'isAVowel',
categoryId: 'sensors'
}
Expand Down

0 comments on commit 04c8fdb

Please sign in to comment.