Skip to content

feat: break input types into separate classes#7019

Merged
BeksOmega merged 8 commits into
RaspberryPiFoundation:developfrom
BeksOmega:feat/input-types
May 4, 2023
Merged

feat: break input types into separate classes#7019
BeksOmega merged 8 commits into
RaspberryPiFoundation:developfrom
BeksOmega:feat/input-types

Conversation

@BeksOmega
Copy link
Copy Markdown
Contributor

The basics

  • I branched from develop
  • My pull request is against develop
  • My code follows the style guide
  • I ran npm run format and npm run lint

The details

Resolves

Work on #2062

Proposed Changes

Splits all of the different types of inputs out into individual classes.

Reason for Changes

This matches how we want external developers to define custom inputs. And also matches people's mental models better.

Test Coverage

N/A - Should be covered by existing tests.

Documentation

N/A

Additional Information

We could mark the constructors for the new inputs @internal out of an abundance of caution. But I don't think there's any real risk to letting external developers construct them.

Best to review commit-wise!

@BeksOmega BeksOmega requested a review from a team as a code owner April 26, 2023 21:45
@BeksOmega BeksOmega requested a review from NeilFraser April 26, 2023 21:45
@github-actions github-actions Bot added the PR: feature Adds a feature label Apr 26, 2023
@BeksOmega BeksOmega requested a review from maribethb April 26, 2023 21:46
@BeksOmega
Copy link
Copy Markdown
Contributor Author

@maribethb I added you as a reviewer purely for the design-y / api-y bits of this. No need to do a nitty-gritty code review I (unless you want to), just want feedback on the approach.

Comment thread core/inputs/dummy_input.ts Outdated
Comment thread core/inputs/statement_input.ts Outdated
Comment thread core/block.ts Outdated
Comment thread blocks/lists.ts Outdated
Comment thread core/inputs/input.ts Outdated
Comment thread core/blockly.ts
import {inject} from './inject.js';
import {Align, Input} from './input.js';
import {inputTypes} from './input_types.js';
import {Align, Input} from './inputs/input.js';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the intention for developers to use Blockly.inputs.Input now? Can you fix the comments on the @see tags for ALIGN_LEFT et al in this file (line 200 or so) if so?

Although, if we do want people to change the import path for input, now might be a good time to break the Align enum into its own file, so that we can eventually get rid of the Input namespace, which is not recommended and makes our documentation more confusing. We could continue to export the new enum from the old location for now.

So new would be
Blockly.input.Input and Blockly.input.Align.LEFT

and old (deprecated, to be removed) would be Blockly.Input and Blockly.Input.Align.LEFT aka Blockly.ALIGN_LEFT

wdyt? If you don't intend external developers to update their usage then this is all moot, I just think it might be nice to fix while we're here and changing things.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that's reasonable! That would be a breaking change though correct? If so I think it would be better too do that in a separate PR so we can link to it & include just what broke.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should make it a deprecating change, and remove the old stuff in v11. But yes, doing it in its own PR so we can link to it from release notes makes sense.

@BeksOmega BeksOmega force-pushed the feat/input-types branch from ba4a450 to d6489f4 Compare May 3, 2023 18:20
@BeksOmega BeksOmega merged commit 3a9a9bd into RaspberryPiFoundation:develop May 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: feature Adds a feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants