Initial editor tabs implementation with CAD package guides #519

Merged
franknoirot merged 12 commits from editor-tabs into main 2021-09-20 09:55:30 +02:00
franknoirot commented 2021-09-19 05:25:52 +02:00 (Migrated from github.com)

https://user-images.githubusercontent.com/23481541/133914435-d9443aba-79f2-41d7-a48c-da8a8ecac9ba.mp4

Implemented

  • rudimentary tabs and tab actions:
    • create new tabs (only by clicking CAD Package Guide button)
    • close tab
    • switch between tabs
  • click CAD package button

Not implemented

  • reordering tabs
  • closing the Code tab
  • "Skip to Cheat Sheet" link shown in the Figma designs
  • cheat sheet table styling or content
  • all CAD package content should be polished up and approved by the respective teams

Other Work

  • Added raw-loader to Webpack to allow the following file types to be imported as raw text:
    • .SCAD
    • .py
    • .jscad
    • .md
    • cleaned up useIdeState using this to break out initialCode and userGuide files for each CAD package within their own directories.
    • cleaned up a bit of the CadPackage component
https://user-images.githubusercontent.com/23481541/133914435-d9443aba-79f2-41d7-a48c-da8a8ecac9ba.mp4 ## Implemented - rudimentary tabs and tab actions: - create new tabs (only by clicking CAD Package Guide button) - close tab - switch between tabs - click CAD package button ## Not implemented - reordering tabs - closing the Code tab - "Skip to Cheat Sheet" link shown in the [Figma designs](https://www.figma.com/file/VUh53RdncjZ7NuFYj0RGB9/CadHub?node-id=1114%3A2062) - cheat sheet table styling or content - all CAD package content should be polished up and approved by the respective teams ## Other Work - Added `raw-loader` to Webpack to allow the following file types to be imported as raw text: - `.SCAD` - `.py` - `.jscad` - `.md` - cleaned up `useIdeState` using this to break out `initialCode` and `userGuide` files for each CAD package within their own directories. - cleaned up a bit of the `CadPackage` component
franknoirot (Migrated from github.com) reviewed 2021-09-19 05:41:21 +02:00
@@ -0,0 +50,4 @@
{matches[1]}
</a>
)
}
franknoirot (Migrated from github.com) commented 2021-09-19 05:32:05 +02:00

Overengineered? Definitely. But I really wanted to get links into the meta fields for this and for people to be able to edit them easily using the standard YAML frontmatter in GitHub-flavored Markdown. So this checks if the metadata value is a Markdown-style link.

Overengineered? Definitely. But I really wanted to get links into the meta fields for this and for people to be able to edit them easily using the standard YAML frontmatter in GitHub-flavored Markdown. So this checks if the metadata value is a Markdown-style link.
franknoirot (Migrated from github.com) commented 2021-09-19 05:32:53 +02:00

I wasn't sure how to handle the INIT type but I didn't want those red squiggles anymore.

I wasn't sure how to handle the INIT type but I didn't want those red squiggles anymore.
franknoirot (Migrated from github.com) commented 2021-09-19 05:37:36 +02:00

This should probably be broken out into a new component soon. I can do it now if you think I should @Irev-Dev.

This should probably be broken out into a new component soon. I can do it now if you think I should @Irev-Dev.
@@ -272,0 +229,4 @@
...state.models.slice(payload + 1),
],
currentModel: payload === 0 ? 0 : payload - 1,
}
franknoirot (Migrated from github.com) commented 2021-09-19 05:39:25 +02:00

These are not used anywhere yet, so I haven't gotten to test them out.

These are not used anywhere yet, so I haven't gotten to test them out.
franknoirot (Migrated from github.com) reviewed 2021-09-19 06:42:33 +02:00
@@ -3,3 +2,4 @@
import { cadPackages, initCodeMap, initGuideMap } from 'src/helpers/cadPackages'
import type { RootState } from '@react-three/fiber'
import type {
RawCustomizerParams,
franknoirot (Migrated from github.com) commented 2021-09-19 06:42:33 +02:00

These work but cause TS errors in VS Code. Unsure how to fix but will investigate, I have a hunch that .d.ts files might help this?

These work but cause TS errors in VS Code. Unsure how to fix but will investigate, I have a hunch that `.d.ts` files might help this?
franknoirot (Migrated from github.com) reviewed 2021-09-19 07:06:50 +02:00
@@ -3,3 +2,4 @@
import { cadPackages, initCodeMap, initGuideMap } from 'src/helpers/cadPackages'
import type { RootState } from '@react-three/fiber'
import type {
RawCustomizerParams,
franknoirot (Migrated from github.com) commented 2021-09-19 07:06:29 +02:00

Got it fixed with globals.d.ts file

Got it fixed with `globals.d.ts` file
Irev-Dev (Migrated from github.com) approved these changes 2021-09-19 10:01:56 +02:00
Irev-Dev (Migrated from github.com) left a comment

I made a couple small suggestions, so I won't merge, but it's approved so merge when you're ready :)

As is my style these days I need make an extra commit that you can pull in if you like
bb4659a2dd (there's a comment there too with a bit of an explanation)

I made a couple small suggestions, so I won't merge, but it's approved so merge when you're ready :) As is my style these days I need make an extra commit that you can pull in if you like https://github.com/Irev-Dev/cadhub/commit/bb4659a2dd480957845caae1ea75ee6dafc6ac64 (there's a comment there too with a bit of an explanation)
Irev-Dev (Migrated from github.com) commented 2021-09-19 09:57:34 +02:00

This is a really nice solution.

This is a really nice solution.
@@ -9,0 +11,4 @@
openscad: {
label: 'OpenSCAD',
buttonClasses: 'bg-yellow-800',
dotClasses: 'bg-yellow-200',
Irev-Dev (Migrated from github.com) commented 2021-09-19 08:42:11 +02:00

😁

😁
Irev-Dev (Migrated from github.com) commented 2021-09-19 09:41:01 +02:00

I don't think we need to do that now, its a 90 line file, not screaming to be broken down yet.
Maybe if tabs get more complex.

I don't think we need to do that now, its a 90 line file, not screaming to be broken down yet. Maybe if tabs get more complex.
Irev-Dev (Migrated from github.com) commented 2021-09-19 09:45:36 +02:00

Just thinking ahead here and leaving some thoughts;
When changing tabs between code tabs, I hope there won't be any trouble just updating state (value and language in particular). There is a "recommended" way of doing tabs with monaco, but don't think it really applies to @monaco-editor/react

Just thinking ahead here and leaving some thoughts; When changing tabs between code tabs, I hope there won't be any trouble just updating state (`value` and `language` in particular). There is a "[recommended](https://github.com/Microsoft/monaco-editor/issues/604#issuecomment-344214706)" way of doing tabs with monaco, but don't think it really applies to `@monaco-editor/react`
Irev-Dev (Migrated from github.com) commented 2021-09-19 09:28:03 +02:00

I think Torsten is the current maintainer, but am not sure. Probably a good starting point I guess ideally these files would be maintain by a person from each project.
I should add a .md file in src/helpers/cadPackages thats an explanation of how the integrations work, as there are more parts to it now as well.

I think Torsten is the current maintainer, but am not sure. Probably a good starting point I guess ideally these files would be maintain by a person from each project. I should add a `.md` file in `src/helpers/cadPackages` thats an explanation of how the integrations work, as there are more parts to it now as well.
Irev-Dev (Migrated from github.com) commented 2021-09-19 09:34:40 +02:00

Do you think that moving this map as well as initCodeMap to src/helpers/cadPackages/index.ts then importing into this file would make sense?
Would clean up the imports in this file and keeps the cad package config together more?

Do you think that moving this map as well as `initCodeMap` to `src/helpers/cadPackages/index.ts` then importing into this file would make sense? Would clean up the imports in this file and keeps the cad package config together more?
@@ -272,0 +229,4 @@
...state.models.slice(payload + 1),
],
currentModel: payload === 0 ? 0 : payload - 1,
}
Irev-Dev (Migrated from github.com) commented 2021-09-19 09:31:22 +02:00

Could we maybe comment these out then?
I think that a good compromise between "we're going to use them very soon so lets leave them" and "Lets not add dead code to the project".

Could we maybe comment these out then? I think that a good compromise between "we're going to use them very soon so lets leave them" and "Lets not add dead code to the project".
Irev-Dev (Migrated from github.com) commented 2021-09-19 08:40:37 +02:00

Maybe this falls into the bucket of preemptive optimisations but I think it's okay since its not adding much more complexity or new patterns. Basically I'm not sure how expensive regular expressions can be to run over and over so might be best to play it safe

export function useMarkdownMetaData(text: string): Array<any> {
  return React.useMemo(() => {
    const metaData = {} as any
    /* ... */
    return [rawMetaData, metaData]
  }, [text])
}
Maybe this falls into the bucket of preemptive optimisations but I think it's okay since its not adding much more complexity or new patterns. Basically I'm not sure how expensive regular expressions can be to run over and over so might be best to play it safe ```suggestion export function useMarkdownMetaData(text: string): Array<any> { return React.useMemo(() => { const metaData = {} as any /* ... */ return [rawMetaData, metaData] }, [text]) } ```
Irev-Dev (Migrated from github.com) requested changes 2021-09-19 12:20:14 +02:00
Irev-Dev (Migrated from github.com) left a comment

Hey, removing approval because the user profile seems to be broken on this branch.
getting:

Uncaught TypeError: Cannot read properties of undefined (reading 'buttonClasses')
    at CadPackage (CadPackage.tsx:51)

Since there are changes to that file I'm guessing it's causing an issue

Hey, removing approval because the user profile seems to be broken on this branch. getting: ``` Uncaught TypeError: Cannot read properties of undefined (reading 'buttonClasses') at CadPackage (CadPackage.tsx:51) ``` Since there are changes to that file I'm guessing it's causing an issue
franknoirot (Migrated from github.com) reviewed 2021-09-19 15:49:30 +02:00
franknoirot (Migrated from github.com) commented 2021-09-19 15:49:30 +02:00

Ah of course I hadn't thought of this rerendering a bunch of times! Thank you seems very helpful.

Ah of course I hadn't thought of this rerendering a bunch of times! Thank you seems very helpful.
franknoirot (Migrated from github.com) reviewed 2021-09-19 15:51:37 +02:00
franknoirot (Migrated from github.com) commented 2021-09-19 15:51:37 +02:00

Sweet I can ask him in Discord about the maintainer things, Marius was justed on the main site still.

Sweet I can ask him in Discord about the maintainer things, Marius was justed on the main site still.
franknoirot (Migrated from github.com) reviewed 2021-09-19 16:01:58 +02:00
franknoirot (Migrated from github.com) commented 2021-09-19 16:01:58 +02:00

Oh yeah I definitely want to do that Monaco best practice if I understand you correctly! I named the field models so that when the time comes we can add each code tab as true models with their own language and current state settings. I think code prop on IdeState will need to change or merge with models when we tackle multi-file

Oh yeah I definitely want to do that Monaco best practice if I understand you correctly! I named the field `models` so that when the time comes we can add each code tab as true models with their own language and current state settings. I think `code` prop on `IdeState` will need to change or merge with `models` when we tackle multi-file
franknoirot (Migrated from github.com) reviewed 2021-09-19 16:02:49 +02:00
franknoirot (Migrated from github.com) commented 2021-09-19 16:02:49 +02:00

Yeah that does sound good I'll give it a shot

Yeah that does sound good I'll give it a shot
franknoirot commented 2021-09-19 16:06:23 +02:00 (Migrated from github.com)

Ah geez thanks for catching that, I should have realized that the CadPackage button is used in several places and needed broader testing. I'm pretty sure it's related to the onClick prop I added but I'll check it out.

Ah geez thanks for catching that, I should have realized that the `CadPackage` button is used in several places and needed broader testing. I'm pretty sure it's related to the `onClick` prop I added but I'll check it out.
franknoirot (Migrated from github.com) reviewed 2021-09-19 16:21:25 +02:00
franknoirot (Migrated from github.com) commented 2021-09-19 16:21:25 +02:00

Yeah sounds good, I'm thinking whenever we need to add drag and drop reordering of tabs.

Yeah sounds good, I'm thinking whenever we need to add drag and drop reordering of tabs.
franknoirot (Migrated from github.com) reviewed 2021-09-19 16:21:46 +02:00
@@ -272,0 +229,4 @@
...state.models.slice(payload + 1),
],
currentModel: payload === 0 ? 0 : payload - 1,
}
franknoirot (Migrated from github.com) commented 2021-09-19 16:21:46 +02:00

Of course, good call.

Of course, good call.
franknoirot (Migrated from github.com) reviewed 2021-09-19 17:21:11 +02:00
@@ -8,6 +8,7 @@ export const QUERY = gql`
id
title
mainImage
cadPackage
franknoirot (Migrated from github.com) commented 2021-09-19 17:10:51 +02:00

@Irev-Dev I didn't catch that we didn't have the cadPackage badges showing on the UserProfile before!

@Irev-Dev I didn't catch that we didn't have the cadPackage badges showing on the UserProfile before!
franknoirot (Migrated from github.com) reviewed 2021-09-19 17:27:23 +02:00
@@ -8,6 +8,7 @@ export const QUERY = gql`
id
title
mainImage
cadPackage
franknoirot (Migrated from github.com) commented 2021-09-19 17:27:22 +02:00

It wasn't related to onClick because I made that optional, but rather the reworking to make it a config with dotClasses and buttonClasses based on the current CAD Package which was undefined in UserProfile because of this missing query field.

It wasn't related to `onClick` because I made that optional, but rather the reworking to make it a config with `dotClasses` and `buttonClasses` based on the current CAD Package which was undefined in `UserProfile` because of this missing query field.
Irev-Dev (Migrated from github.com) reviewed 2021-09-19 21:14:53 +02:00
@@ -8,6 +8,7 @@ export const QUERY = gql`
id
title
mainImage
cadPackage
Irev-Dev (Migrated from github.com) commented 2021-09-19 21:14:53 +02:00

Ah nice.

Ah nice.
Irev-Dev (Migrated from github.com) requested changes 2021-09-19 22:15:16 +02:00
Irev-Dev (Migrated from github.com) left a comment

Sorry I haven't been able to find everything in one go, but I noticed that cadPackage badge thing on the project profile now has a pointer but clicking it does nothing, which is not the case in main.

https://user-images.githubusercontent.com/29681384/133941682-c5f999dd-20c8-4812-bfde-57dc5264c893.mov

Could we either remove the pointer or make clicking do something? I'm not sure which is better.

Sorry I haven't been able to find everything in one go, but I noticed that cadPackage badge thing on the project profile now has a pointer but clicking it does nothing, which is not the case in main. https://user-images.githubusercontent.com/29681384/133941682-c5f999dd-20c8-4812-bfde-57dc5264c893.mov Could we either remove the pointer or make clicking do something? I'm not sure which is better.
hrgdavor commented 2021-09-19 22:18:10 +02:00 (Migrated from github.com)

mini settings button is confusing me
image

I can click it to open settings, but can not use it to close settings

had to look all the way down left to see the big button for settings and use that to close the settings

mini settings button is confusing me ![image](https://user-images.githubusercontent.com/2480762/133941739-54759e51-783e-4143-ac35-f3a6e40d09d6.png) I can click it to open settings, but can not use it to close settings had to look all the way down left to see the big button for settings and use that to close the settings
Irev-Dev commented 2021-09-19 22:23:38 +02:00 (Migrated from github.com)

mini settings button is confusing me

It's somewhat intentional (in that it's a compromise we're okay with for now), we'll keep it in mind. (#507)

> mini settings button is confusing me It's somewhat intentional (in that it's a compromise we're okay with for now), we'll keep it in mind. (#507)
franknoirot commented 2021-09-19 22:52:59 +02:00 (Migrated from github.com)

@Irev-Dev Ah yes can do, I had removed the hover background opacity change but didn't remove the cursor pointer setting.

Ah @hrgdavor yeah some control tweaks will probably come later and animations will help make that relationship more clear.

@Irev-Dev Ah yes can do, I had removed the hover background opacity change but didn't remove the cursor pointer setting. Ah @hrgdavor yeah some control tweaks will probably come later and animations will help make that relationship more clear.
franknoirot (Migrated from github.com) reviewed 2021-09-19 23:04:26 +02:00
@@ -17,3 +42,4 @@
className = '',
dotClass = 'w-5 h-5',
onClick,
}: CadPackageProps) => {
franknoirot (Migrated from github.com) commented 2021-09-19 23:04:20 +02:00

@Irev-Dev I thought about simply leaving the button and removing the cursor: pointer if no onClick is provided, but I think this is more semantic and will prevent some future "button cannot be child of button" warnings in future.

@Irev-Dev I thought about simply leaving the button and removing the `cursor: pointer` if no `onClick` is provided, but I think this is more semantic and will prevent some future "button cannot be child of button" warnings in future.
Irev-Dev (Migrated from github.com) reviewed 2021-09-19 23:22:18 +02:00
@@ -17,3 +42,4 @@
className = '',
dotClass = 'w-5 h-5',
onClick,
}: CadPackageProps) => {
Irev-Dev (Migrated from github.com) commented 2021-09-19 23:22:18 +02:00
Looks good, dynamic tag is also an option https://stackoverflow.com/questions/33471880/dynamic-tag-name-in-jsx-and-react
franknoirot commented 2021-09-19 23:25:42 +02:00 (Migrated from github.com)

And @Irev-Dev you don't have to be sorry, I am. I should be doing this work before you review. I think I'm starting to understand how to assess where to test for regressions, looking for other places where a component I'm working on is used in other contexts and such.

And @Irev-Dev you don't have to be sorry, I am. I should be doing this work before you review. I think I'm starting to understand how to assess where to test for regressions, looking for other places where a component I'm working on is used in other contexts and such.
franknoirot (Migrated from github.com) reviewed 2021-09-19 23:49:24 +02:00
@@ -17,3 +42,4 @@
className = '',
dotClass = 'w-5 h-5',
onClick,
}: CadPackageProps) => {
franknoirot (Migrated from github.com) commented 2021-09-19 23:49:24 +02:00

Oh nice this is more the stuff I was looking for! In this case I'm cool with the way I did it because I also added the class name, but I'll keep this in mind in future yeah?

Oh nice this is more the stuff I was looking for! In this case I'm cool with the way I did it because I also added the class name, but I'll keep this in mind in future yeah?
Irev-Dev (Migrated from github.com) reviewed 2021-09-19 23:53:41 +02:00
@@ -17,3 +42,4 @@
className = '',
dotClass = 'w-5 h-5',
onClick,
}: CadPackageProps) => {
Irev-Dev (Migrated from github.com) commented 2021-09-19 23:53:41 +02:00

Yup, thats what I was going for, just an FYI if you weren't aware of it 😁

Yup, thats what I was going for, just an FYI if you weren't aware of it 😁
Irev-Dev (Migrated from github.com) approved these changes 2021-09-20 09:55:11 +02:00
Irev-Dev (Migrated from github.com) left a comment

Yay, thanks for bearing with me.

I did find one more bug, but it's a trivial and amusing one, will get clean up with more tab work.

https://user-images.githubusercontent.com/29681384/133971317-598bdb14-7929-48fa-95ee-9cf85b2850ca.mov

Yay, thanks for bearing with me. I did find one more bug, but it's a trivial and amusing one, will get clean up with more tab work. https://user-images.githubusercontent.com/29681384/133971317-598bdb14-7929-48fa-95ee-9cf85b2850ca.mov
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: h3n3/cadhub#519