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

ui: code-editor-styling #11474

Merged
merged 21 commits into from
Nov 12, 2021
Merged

Conversation

deblasis
Copy link
Contributor

@deblasis deblasis commented Nov 2, 2021

This PR should address #11224, submitting it as WIP so that we can agree on the right way forward.

It also lacks functionality.
The missing deliverables are marked as TODOs and there's also a blatant HACK (first time using Ember so forgive me if I made blatant mistakes).

There's also commented code with an explanation of what I was trying to achieve.
Eventually, I'll figure it out 😊

Tasklist:

  • Figure out how to conditionally render the help link inside the title of the toolbar
  • For wider screens we should not stretch to fill but simply match the width of the other components
  • Fix toolbar styling variables using color palette
  • Change dropdown to match the desired styling
  • It happens only in the policies pages but clicking on the editor activates copy-button onClick event handler, works fine for KV 😕
  • Toolbar component SCSS files inside its folder are ignored for some reason
  • Refactoring: cleanup styles and DOM
  • Refactoring: split styles into their respective layout.scss and skin.scss
  • Refactoring: CodeEditor label named block
  • Refactoring: CodeEditor toolbar tools named block
  • Refactoring: CodeEditor content named block
  • Docs: code-editor/README.mdx

shame level: HIGH

lots of TODOs and also a HACK to be handled.
This commit will have to be reworded as well

Signed-off-by: Alessandro De Blasis <alex@deblasis.net>
@vercel vercel bot temporarily deployed to Preview – consul November 2, 2021 13:42 Inactive
@deblasis deblasis marked this pull request as ready for review November 2, 2021 13:46
@johncowen johncowen self-assigned this Nov 2, 2021
@johncowen johncowen added the theme/ui Anything related to the UI label Nov 2, 2021
Signed-off-by: Alessandro De Blasis <alex@deblasis.net>
@vercel vercel bot temporarily deployed to Preview – consul November 2, 2021 15:08 Inactive
@johncowen
Copy link
Contributor

Hey @deblasis

Firstly thanks for picking this up! I'll see if I can answer your initial questions from the ticket here:

  1. What is the expected behaviour for the "wider screen resizing"? Shall we stretch to fill the page consistently with the other parts of the UI? I don't want to make assumptions, the current width has been capped for routes that are create or edit via UI: Feature: ui css refactor UI: Feature: ui css refactor #4430 and then the code editor (CodeMirror component) received similar width capping with ui: Adds multi syntax linting to the code editor ui: Adds multi syntax linting to the code editor #4814 so I wouldn't want to cause regressions. Also, maybe irrelevant, but Vault centres content instead of stretching it.

It should stay to the same width as the other elements on the page. I'd say generally (and in the case of the screengrab you added) the width of the 'name' of the thing you are editing, so for creating a KV the width of the key input field for the KV. Actually I just checked I guess this width is the same as the grey keyline under the title, maybe this helps:

Screenshot 2021-11-03 at 12 26 49

  1. What about smaller resolutions? Can I safely assume that it should behave as it stands?

I think so, currently looks good to me. I think we may have specifically put the JSON menu outside the box to keep as much editing room as possible (I might be misremembering there) but we are moving this menu up top now anyway.:

Screenshot 2021-11-03 at 12 28 24

How can I get access to the Figma design?

I'm guessing we might not be able to share that, what is it you'd need here? Maybe we can figure something out.

So far I have been fiddling with the code and while being inspired by copying Vault styling for the toolbar I got to this (still WIP!):

If it was me I'd probably start from scratch, there seems to be a lot of code currently added here that looks like it adds a grey bar. I think you know this already judging by your comments but if you are copying pasting things over, you are probably bringing over a load of things you don't need.

  1. Ember sounds quite intuitive, I am pretty happy that the copy button works already even if I have an issue with component styling that I am not raising yet since I don't want to go OT too much, perhaps I'll ask for help later on unless I figure out in the meantime.

Could you elaborate the issue with the component styling? Can I help there? Is this the copy button component or the code editor component?

  1. Is there already a component with the desired styling for the "code mode" (JSON, HCL, YAML) dropdown? I remember seeing that dropdown somewhere but I can't remember where. Perhaps I could get that from the design 🤔

I'd probably just go with something simple, either use something thats already there. Looking at the screengrab you provided in #11224 (comment), you could probably more or less just turn what you have there gray (the same gray as in the design) and give it a bit more padding/border. In the meantime I can look see if I can get you an open state if that helps. I think overall though, the most important thing here is to fix the responsive width of the editor, if we want to add another style of dropdown menus to the UI we could potentially tackle that as a separate ticket/PR.

Ok so that's your initial questions covered, I'm going to go over the questions in the code in a bit and see what I can help with there, plus now we have an open PR we can use the inline code comments for specific line items. One thing I did notice from your screengrab is we've lost the little code toggle thing, but it might be hiding behind the menu, I need to look proper at your code. Be back in a bit 👍

@deblasis
Copy link
Contributor Author

deblasis commented Nov 3, 2021

Hi @johncowen, thanks for clarifying!

I asked for the design in order to extract the CSS and make the dropdown pixel perfect but if it's not needed I am happy to make it similar enough.

Looking forward to your review/guidance so that I can resume working on it.
Hopefully, my code didn't hurt your eyes too much!

Cheers

@johncowen
Copy link
Contributor

😆

Sounds good! I'm gonna be afk for a bit but I just pushed a thing I had hanging around that might help here in the meantime. I still need to look at the code properly, but this might help you with colors which I think I saw a comment about.

https://consul-ui-staging-akmozj0z6-hashicorp.vercel.app/ui/docs/colors

I'll come back a little later to 👀 better, I'm sure they won't end up bleeding 😆 👍

Thanks!

not sure if it's the best practice but I used a hash to achieve
conditional rendering of the help link by passing a prop to CodeEditor

Signed-off-by: Alessandro De Blasis <alex@deblasis.net>
@vercel vercel bot temporarily deployed to Preview – consul November 3, 2021 16:31 Inactive
Signed-off-by: Alessandro De Blasis <alex@deblasis.net>
@vercel vercel bot temporarily deployed to Preview – consul November 3, 2021 17:14 Inactive
Signed-off-by: Alessandro De Blasis <alex@deblasis.net>
@vercel vercel bot temporarily deployed to Preview – consul November 3, 2021 18:19 Inactive
Signed-off-by: Alessandro De Blasis <alex@deblasis.net>
@vercel vercel bot temporarily deployed to Preview – consul November 3, 2021 18:25 Inactive
@johncowen
Copy link
Contributor

Hey @deblasis , its the end of my day but I can see you adding to this so wanted to quickly drop the term 'named blocks' for Ember in for your question around passing links through into a component. They are like HTML slots.

Sorry this is a little piecemeal, I've been really busy today. I wanted to leave a bit more for you to help today then I've been able to, promise I'll spend more time with you/it tomorrow. 👍

@deblasis
Copy link
Contributor Author

deblasis commented Nov 3, 2021

Hey @johncowen! No worries at all!
I hacked my way using a hash and then rendering conditionally inside the component, I am gonna have a look at "named blocks" aaaaanddd..... a quick search reveals that it's exactly what I was looking for without knowing how to search for it 😆! Thanks! 🙏

I also added a tasklist in the PR description for what I think is still pending but of course, your review is gonna dictate what's left to do.

shame level: HIGH

lots of TODOs and also a HACK to be handled.
This commit will have to be reworded as well

Signed-off-by: Alessandro De Blasis <alex@deblasis.net>
Signed-off-by: Alessandro De Blasis <alex@deblasis.net>
not sure if it's the best practice but I used a hash to achieve
conditional rendering of the help link by passing a prop to CodeEditor

Signed-off-by: Alessandro De Blasis <alex@deblasis.net>
Signed-off-by: Alessandro De Blasis <alex@deblasis.net>
Signed-off-by: Alessandro De Blasis <alex@deblasis.net>
Signed-off-by: Alessandro De Blasis <alex@deblasis.net>
Signed-off-by: Alessandro De Blasis <alex@deblasis.net>
@vercel vercel bot temporarily deployed to Preview – consul November 4, 2021 08:36 Inactive
Signed-off-by: Alessandro De Blasis <alex@deblasis.net>
@vercel vercel bot temporarily deployed to Preview – consul November 4, 2021 08:39 Inactive
@johncowen
Copy link
Contributor

Just in and took a quick scan of this, and I just wanted to say real quick that this is looking awesome 👏

There will be a few things that I'd like to 'move around' I think, but let me get settled in and I'll give it a proper look 👍

@deblasis
Copy link
Contributor Author

deblasis commented Nov 4, 2021

Just in and took a quick scan of this, and I just wanted to say real quick that this is looking awesome 👏

There will be a few things that I'd like to 'move around' I think, but let me get settled in and I'll give it a proper look 👍

Fantastic! Thank you @johncowen! Well, you helped, I have to give you credit.

Copy link
Contributor

@johncowen johncowen left a comment

Choose a reason for hiding this comment

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

This is looking super good. I left some itty bitty inline comments, but at a more general level following your lead on what you've already done here I'd like:

  1. Would be nice if CodeEditor had a <:toolbar> slot/block. I can see us having different toolbars per CodeEditor/Form. If we have a <:toolbar> it means we can configure this from The Outside depending on the page we are on (the link etc would all go in the toolbar)
  2. I think we should maybe not use :default for a name of a block, not entirely sure but from what I know about it it's potentially confusingly also the block for when no named blocks are specified, which scares me a little. Maybe use :content? I think we use that name elsewhere for the main contents of something. Bit of a nit this one all in all.
  3. I'm still unsure as to whether we need a brand new Toolbar component, especially if we change to have a <:toolbar> slot. I need to look at this a bit further as maybe we do. I'm still curious about the fact that there seems to be a lot of CSS going on for the toolbar so I'll think about this at the same time - just wanted to share thoughts with you there - lemme know if you have anything yourself on that one.

I'm likely to come back shortly with comments on that Toolbar component, so up to you whether you want to start on changes now or wait until then (shouldn't be too long)

Lastly, again super good this, thankyou!

display: flex;
align-items: center;
flex-direction: row;
}
Copy link
Contributor

@johncowen johncowen Nov 4, 2021

Choose a reason for hiding this comment

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

There are a few missing rgb here. I dunno if you noticed but in the ColorSwatch docs things I linked to, if you click on the swatch it copies the value (inc. rgb) to the clipboard.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I noticed but I was getting the wrong colours because of the dark mode I guess so I ended up writing manually (the wrong thing).

Also I noticed that there were some inconsistencies in that file already, see

background-color: rgb(var(--black));
and

Copy link
Contributor

@johncowen johncowen Nov 4, 2021

Choose a reason for hiding this comment

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

Yup only --tones should use the rgb syntax. Any colours without --tone should pretty much be ignored/not used.


%code-editor .ember-basic-dropdown-trigger {
background-color: var(--tone-gray-900);
color: var(--black);
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you use --tone-gray-000 for this please? (instead of --black)

All of the --tones are themeable --tone-gray-000 is black (in light mode) and --tone-gray-999 is white. We have this "quick dark mode" thing which just reverses the gray tones (so 000 = white and 999 = black), which gets us almost to dark mode or high contrast mode really easily.

So glad you did it like this though (but I'd like you to change) as it means I know I need to add this to our color docs 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I must be using the dark mode because
image
comes from this:
image
I just pushed this specific change.

Copy link
Contributor

Choose a reason for hiding this comment

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

background-color: var(--tone-gray-900);
color: var(--black);
border-radius: 2px;
border: 1px solid;
Copy link
Contributor

Choose a reason for hiding this comment

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

Not super important but we have some more props for these if you could use those

https://github.com/hashicorp/consul/blob/main/ui/packages/consul-ui/app/styles/base/decoration/base-variables.scss#L4-L10

Documentation for all this coming soon!

height: 32px;
margin: 0 4px;
width: 0;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Feels like there a lot here, so I'm gonna take a deeper look, so up to you if you want to make changes now or wait til then. but generally:

  1. If you could use that CSS props for decoration things like borders etc that I linked to above that'd be great.
  2. Use a tone instead of black (as above)
  3. All in all this will need splitting into layout and skin files - but we can leave that until absolute last thing as its just cleanup/consistency - I'd rather get everything finished and then do a final clean up, but up to you if you wanted to do it now instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree and I like the splitting, right, since I am going to refactor the Toolbar anyway now that I know how to do it ;)
I will let you know when this is ready for review again so that I don't waste too much of your time.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds great 👍

@@ -24,7 +24,7 @@ $syntax-dark-gray: #535f73;
--syntax-yellow: rgb(var(--tone-yellow-500));
}
.CodeMirror {
max-width: 1150px;
max-width: 1260px;
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh dear 😆 it was just this 🤣 . Surprising nobody has tweaked this before now 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I know, right? It happens, it's always a single line of code that is holding things together or that breaks everything :)

{{yield}}
</div>
</nav>
</nav>
Copy link
Contributor

@johncowen johncowen Nov 4, 2021

Choose a reason for hiding this comment

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

afaik nav should only be used for site / app main nav (or sub nav or whatever) but its generally a way to navigate around the site / app rather than for a toolbar thing. I'd just stick with div here unless you can suggest something else? (I'd be concerned about suggesting menu as I vaguely remember browser difference/complications from a while back but I've no idea if thats still relevant, so unless you know more I'd maybe err on the side of caution with a div)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I stole this from Vault and I played ignorantly to be honest but yeah, it is especially weird because we have nested nav too. I'll change that.

@johncowen
Copy link
Contributor

Toolbar component SCSS files inside its folder are ignored for some reason

Sorry missed this. Ember doesn't auto include the CSS files for the component (we have work hanging around to make it do this, which funnily enough we were chatting about amongst the team today).

We currently manually include component CSS files here:

https://github.com/hashicorp/consul/blob/main/ui/packages/consul-ui/app/styles/components.scss

(this ^ file is then included by the app.css file which Ember pulls in)

I'd probably wait until I've stared at the toolbar stuff a little more though before moving stuff around as I'm just thinking whether we want to include the styling for the toolbar in the CodeEditor component ( I can't think of a reason why we'd use a this toolbar component as part of anything other than this CodeEditor right now 🤔 )

It happens only in the policies pages but clicking on the editor activates copy-button onClick event handler, works fine for KV 😕

👀 looking now

I did notice a little bug with our CopyButton tho! It doesn't do anything if the thing you are trying to copy is empty (we can add that as a separate task afterwards, just an FYI that this is our problem I think)

@deblasis
Copy link
Contributor Author

deblasis commented Nov 4, 2021

This is looking super good. I left some itty bitty inline comments, but at a more general level following your lead on what you've already done here I'd like:

Well, you made me RTFM a little by pointing me to the right "chapter" 😊

  1. Would be nice if CodeEditor had a <:toolbar> slot/block. I can see us having different toolbars per CodeEditor/Form. If we have a <:toolbar> it means we can configure this from The Outside depending on the page we are on (the link etc would all go in the toolbar)

Sounds sensible, If you are expecting various use cases then it definitely makes sense.
A specific component would be useful if we can figure out the "overridable sane defaults" for a toolbar and then extract the bits that we would want to configure from "the outside".
For example: a minimal toolbar has only a title and an empty placeholder for buttons/controls on the right.

I can definitely refactor this... my train of thought about this continues in point 3 below.

  1. I think we should maybe not use :default for a name of a block, not entirely sure but from what I know about it it's potentially confusingly also the block for when no named blocks are specified, which scares me a little. Maybe use :content? I think we use that name elsewhere for the main contents of something. Bit of a nit this one all in all.

I used the default named block exactly because it's equivalent to putting HTML/Components inside the receiving Component and also Ember doesn't allow you to mix named blocks with the unnamed one.
For example:

<CodeEditor
  @syntax="hcl"
  @readonly={{true}}
>
  <:title>
    Rules <a href="{{env 'CONSUL_DOCS_URL'}}/guides/acl.html#rule-specification" rel="help noopener noreferrer" target="_blank">(HCL Format)</a>
  </:title>
  <:default>
    <Consul::NodeIdentity::Template
      @name={{item.Name}}
    />
  </:default>
</CodeEditor>

It has a title and also it takes the template from that Consul::NodeIdentity::Template.
Originally it was:

<CodeEditor
  @syntax="hcl"
  @readonly={{true}}
>
    <Consul::NodeIdentity::Template
      @name={{item.Name}}
    />
</CodeEditor>

which renders that block inside the default named block.
If we remove the explicit <:default>...</:default> from my example along with the :title we get the error:

/home/alex/CODE/OSS/hashicorp/consul/ui/packages/consul-ui/consul-ui/components/policy-form/index.js: Syntax Error: Unexpected content inside <CodeEditor> component invocation: when using named blocks, the tag cannot contain other content (on line 67 column 12)

Anyway... I guess maybe we can simply rename :default to :template but it would mean that the previous "API" of putting the template inside CodeEditor would break, no biggie I guess but while in doubt I wanted to keep things the way I found them (kinda). 😄
If you agree I'll change that to :template or whatever sounds semantically more correct to you.

  1. I'm still unsure as to whether we need a brand new Toolbar component, especially if we change to have a <:toolbar> slot. I need to look at this a bit further as maybe we do. I'm still curious about the fact that there seems to be a lot of CSS going on for the toolbar so I'll think about this at the same time - just wanted to share thoughts with you there - lemme know if you have anything yourself on that one.

If the toolbar is going to be used in multiple places, it should have its own CSS and be configurable without exposing too much implementation details IMHO. I wanted a separate component because I was "thinking forward" but the fact that I wasn't able to add the SCSS stopped me... now you gave me the power by pointing out how to do that 😂

I'm likely to come back shortly with comments on that Toolbar component, so up to you whether you want to start on changes now or wait until then (shouldn't be too long)

I'll fix the blatant mistakes that you identified commenting atomically on each one if needed and then I'll move forward with the refactoring.

Lastly, again super good this, thankyou!

No worries! You are welcome!

@johncowen
Copy link
Contributor

It happens only in the policies pages but clicking on the editor activates copy-button onClick event handler, works fine for KV 😕

Bit weird I know, but if you put a for="" on the label that wraps the CodeEditor, and that will fix it. Let me know if you are unsure and I'll link you the line.

K, half the reason why this is a bit of a difficult one for me to suggest which way to go is because of ongoing work over here:

https://github.com/hashicorp/consul/tree/main/ui/packages/consul-ui/app/components/text-input

That was building up to a replacement for this CodeEditor component completely. Basically I'm conscious of you doing stuff that we may only use temporarily before moving some of your stuff into that newer component completely (that might never happen).

I guess all in all if we ignore that work is there and you are fine us potentially re-purposing your stuff in that new component at some point in the distant future (the new component will need the ability to show a configurable toolbar) then I think we should:

  1. Make CodeEditor have a <:label> slot. In here goes the text label (plus any link that might be required to explain the text). This will be the left aligned bit of the toolbar.
  2. Make CodeEditor have a <:toolbar> slot. In here goes the tools/widgets and is the right aligned bit of the toolbar.
  3. Make a <:content> block (instead of default) which is the nitpick from previous comments.
  4. We can then forget about a specific Toolbar component as we've replaced it with slots of the CodeEditor.
  5. Styles then all hang of off the %code-editor base selector (lemme know if you are unsure of the %placeholder thing:
%code-editor .thing-for-the-toolbar-slot {}
%code-editor .another-thing {}

Questions from me:

  1. Not sure if I follow why the toolbar stuff has a 'toolbar-scroller'?
  2. The styling for the toolbar still seems like lot of stuff for a gray bar with 2 left/right aligned cells. Is there anything that we can lose there? Could the little dividing line use a CSS based pseudo element instead of an empty div?

Hope this is ok, I'm pretty sure this is mostly just moving what you've done around a bit - if its a bit over the top then lemme know and we can probably do less.

Oh I keep forgetting, I keep meaning to ask you to do a housekeeping task or 2 also. I'm not sure if you can turn this into a Draft PR or not, if you can that means we can lose the WIP out the title. Also we usually prefix all UI PRs (and therefore commits) with ui: so we can filter by that in aeons to come.


Just got your comment in so that ^ is before reading it, this is after reading it (GH tennis!)

re: :default I almost changed my mind as you made me realize that you might do:

<CodeEditor>stuff</CodeEditor>
{{! or }}
<CodeEditor>
  <:toolbar></:toolbar>
  <:default>stuff</:default>
</CodeEditor>
{{! and thats nicer than always having to write default if you have no toolbar like this}}
<CodeEditor><:default>stuff</:default></CodeEditor>
{{! but then I realized you will always want to specify a <:label> (previously :title)}}

All in all I think we should just rename :default to :content (the content isn't always a :template) but honestly no biggie there at all, its just naming.

If the toolbar is going to be used in multiple places

I think the important thing here is it will be used in multiple places but only ever when using the CodeEditor (for the immediate future at least). Maybe think of <:toolbar> as what was <Toolbar>?

Anyway, theres quite a lot here ^ now 😬 , so if you are like "Wo wo wo hold on a second" I'd also be happy to get this in without to much more moving around. I think visually its looks great as is, definitely no eye bleeding 😆

Oh also, if you fancy doing a little more once we are done here, there're docs to fill out in the code-editor/README.mdx but lets finish up here and I can explain how that works if you fancy doing that also (np if not)

Signed-off-by: Alessandro De Blasis <alex@deblasis.net>
@vercel vercel bot temporarily deployed to Preview – consul November 4, 2021 16:34 Inactive
Signed-off-by: Alessandro De Blasis <alex@deblasis.net>
@vercel vercel bot temporarily deployed to Preview – consul November 4, 2021 16:38 Inactive
@deblasis deblasis marked this pull request as draft November 4, 2021 16:57
@deblasis deblasis changed the title WIP: code-editor-styling code-editor-styling Nov 4, 2021
@deblasis
Copy link
Contributor Author

deblasis commented Nov 4, 2021

Good stuff, I am gonna ping you as soon as there's stuff to review and/or questions.

Let me know if I should reword the commit with the ui: prefix and then force push. Sorry about that, I am juggling between projects and each one has its own rules that I obviously keep breaking 😂

Cheers

- :label named block
- :tools named block
- :content named block
- code and CSS cleanup
- CodeEditor.mdx

Signed-off-by: Alessandro De Blasis <alex@deblasis.net>
@vercel vercel bot temporarily deployed to Preview – consul November 4, 2021 20:07 Inactive
@deblasis deblasis changed the title code-editor-styling ui: code-editor-styling Nov 5, 2021
@deblasis
Copy link
Contributor Author

deblasis commented Nov 5, 2021

Hi @johncowen!

Basically I'm conscious of you doing stuff that we may only use temporarily before moving some of your stuff into that newer component completely (that might never happen).

I guess all in all if we ignore that work is there and you are fine us potentially re-purposing your stuff in that new component at some point in the distant future (the new component will need the ability to show a configurable toolbar)

I am totally fine with that, the way I see it: code is per-se an everchanging thing that doesn't have a name on it. I have learnt a tiny bit of ember, worked with nice people, I am good already 😊 one day I'll tell my kids I contributed to consul and they will be proud of me for that too 😉

then I think we should:

  1. Make CodeEditor have a <:label> slot. In here goes the text label (plus any link that might be required to explain the text). This will be the left aligned bit of the toolbar.
  2. Make CodeEditor have a <:toolbar> slot. In here goes the tools/widgets and is the right aligned bit of the toolbar.
  3. Make a <:content> block (instead of default) which is the nitpick from previous comments.
  4. We can then forget about a specific Toolbar component as we've replaced it with slots of the CodeEditor.
  5. Styles then all hang of off the %code-editor base selector (lemme know if you are unsure of the %placeholder thing:
%code-editor .thing-for-the-toolbar-slot {}
%code-editor .another-thing {}

I think I addressed all these points now, I just named :toolbar to :tools instead because it sounded better since in that block we only put tools and the toolbar is at the parent level.
Since it's used only in the CodeEditor for now there's some "sane defaulting" if no tools are specified, I tried to explain that in the README.mdx too.

Questions from me:

  1. Not sure if I follow why the toolbar stuff has a 'toolbar-scroller'?
  2. The styling for the toolbar still seems like lot of stuff for a gray bar with 2 left/right aligned cells. Is there anything that we can lose there? Could the little dividing line use a CSS based pseudo element instead of an empty div?

It was pre-cleanup code that I carelessly stole from Vault 🙈 if I had the designs I would have designed everything from scratch but you know... developers, lazy people.

Hope this is ok, I'm pretty sure this is mostly just moving what you've done around a bit - if its a bit over the top then lemme know and we can probably do less.

No worries! This is like a walk in the park to be honest

Oh I keep forgetting, I keep meaning to ask you to do a housekeeping task or 2 also. I'm not sure if you can turn this into a Draft PR or not, if you can that means we can lose the WIP out the title. Also we usually prefix all UI PRs (and therefore commits) with ui: so we can filter by that in aeons to come.

Just got your comment in so that ^ is before reading it, this is after reading it (GH tennis!)

LOL, agreed, Slack would have been a better way to communicate but despite that, we managed 😄

Oh also, if you fancy doing a little more once we are done here, there're docs to fill out in the code-editor/README.mdx but lets finish up here and I can explain how that works if you fancy doing that also (np if not)

Done, I mean, winging it, let me know if you like what you see.

@deblasis deblasis marked this pull request as ready for review November 5, 2021 07:52
@johncowen
Copy link
Contributor

Sorry for the radio silence here, just a quick FYI in the meantime just waiting to go through this with the team, and then there might be the odd tweak before we merge.

@deblasis
Copy link
Contributor Author

Thanks for the update and no worries @johncowen, take your time.
Happy to make all the required changes if/when needed 👍

Copy link
Contributor

@johncowen johncowen left a comment

Choose a reason for hiding this comment

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

There are a few little things that are tinsy details that are more stylistic than anything so I'm good to merge this as is. The only thing is if we could make the docs page render properly (I added a suggestion which should make it render properly) then we are good to go. You should be able to see this page (if you haven't already) by clicking the [Eng Docs] link in the top right of the UI when you are running in dev mode.

Lemme know once that's done and we can get it merged.

Thanks for your help here 🎉

Co-authored-by: John Cowen <johncowen@users.noreply.github.com>
@vercel vercel bot temporarily deployed to Preview – consul November 12, 2021 15:04 Inactive
@deblasis
Copy link
Contributor Author

I see, sounds good! Suggestion just committed.

You are very welcome 😄

@johncowen johncowen merged commit 53a6134 into hashicorp:main Nov 12, 2021
@hc-github-team-consul-core
Copy link
Contributor

🍒 If backport labels were added before merging, cherry-picking will start automatically.

To retroactively trigger a backport after merging, add backport labels and re-run https://circleci.com/gh/hashicorp/consul/501457.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme/ui Anything related to the UI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants