Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ui): Settings > Indent size #240

Merged
merged 10 commits into from
Sep 13, 2024
Merged

feat(ui): Settings > Indent size #240

merged 10 commits into from
Sep 13, 2024

Conversation

kobenguyent
Copy link
Collaborator

resolves #31

Copy link

netlify bot commented Sep 11, 2024

Deploy Preview for chimerical-kitsune-a0bfa0 ready!

Name Link
🔨 Latest commit 46f9025
🔍 Latest deploy log https://app.netlify.com/sites/chimerical-kitsune-a0bfa0/deploys/66e2e3486b0e0f0008067e07
😎 Deploy Preview https://deploy-preview-240--chimerical-kitsune-a0bfa0.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@flawiddsouza
Copy link
Owner

image
Always move each import to new line. Like how other imports are.

@flawiddsouza
Copy link
Owner

This as well:
image

@flawiddsouza
Copy link
Owner

Let's change the indent size to a select instead of input type number. Provide two options 2 and 4. Let 4 be shown by default if nothing can be retrieved from local storage. We'll add more options if people request it.

Also I saw this:
parseInt(number, 10)

Let the parseInt happen before it reaches the helper method. Add type number to the function param in typescript. Also remove the replacer from parameters of the helper function as it's never used anywhere. It was passed only because it was necessary for json.stringify.

@flawiddsouza
Copy link
Owner

image
selected does nothing when you have a v-model on select, you can remove it.

image
Instead of any, it's best to define the type when you know it and it's simple enough:

export function getEditorConfig(): {
    indentSize: number
} {
    return {
        indentSize: parseInt(localStorage.getItem(constants.LOCAL_STORAGE_KEY.INDENT_SIZE) || constants.EDITOR_CONFIG.indent_size.toString(), 10)
    }
}

export function jsonStringify(data: any, space: number = getEditorConfig().indentSize): any {
    return JSON.stringify(data, null, space)
}

@flawiddsouza
Copy link
Owner

That indent looks weird. I don't know what's wrong with eslint. Let's do one thing, create a new type EditorConfig in packages/ui/src/global.d.ts and use it here.

Also you missed this type I mentioned above:
export function jsonStringify(data: any, space: number = getEditorConfig().indentSize): any {
return JSON.stringify(data, null, space)
}

@flawiddsouza flawiddsouza merged commit 7dabab4 into main Sep 13, 2024
6 checks passed
@flawiddsouza flawiddsouza deleted the feat-editor-indent-size branch September 13, 2024 04:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make it possible to use 2 spaces instead of 4 in the editor
2 participants