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

Add support for adding icons to the CommandList. #23

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

rouilj
Copy link
Contributor

@rouilj rouilj commented Feb 3, 2023

This adds support for placing icons to the left of the commands.

5 cases are supported:

  1. if icon is not defined, it inserts an empty svg that holds 24px of space on the left of the label

  2. if icon is null, the space is not held and the label smooshes to the left

  3. if icon is a character (in span class="icon"), the character is used. If the string is longer than 24 px, it's cut off.

  4. the icon can be an image, css sized to 24x24px.

  5. the icon can be an svg, css sized to 24x24px fill set to currentColor.

in each case the icon is a string "<img ...>" "<svg ...>..." etc see:

#22

for details and examples

John P. rouillard added 4 commits February 3, 2023 02:46
This adds support for placing icons to the left of the commands.

5 cases are supported:

  1. if icon is not defined, it inserts an empty svg that holds 24px of
     space on the left of the label

  2. if icon is null, the space is not held and the label smooshes to
     the left

  3. if icon is a character (in span class="icon"), the character is used.
     If the string is longer than 24 px, it's cut off.

  4. the icon can be an image, css sized to 24x24px.

  5. the icon can be an svg, css sized to 24x24px fill set to currentColor.

in each case the icon is a string "<img ...>" "<svg ...>...</svg>" etc see:

   benwinding#22

for details and examples
add the class cp-placeholder to the svg placeholder inserted when the
icon property is not defined. This allows commands without icon
properties to be flush left in the listbox. Just like using icon: null
on every command, but without having to do all the extra typing.

Added documentation for using icon.

Also updated code to use the "if ( !!var)" idiom.
Changed the height: 36px of the command list item paragraph to be a
min-height: 36px. If the command text gets too long, it is bleeding
over into the other command list rows.

I also set overflow-y: hidden in case somebody adds a max-height or
height to it again. This will stop the bleed over.

Also set flex-shrink:0 on the things that we expect in the icon area.
Also explicity target '.item :first-child' to prevent flex shrinkage
(a bit of defensive css):. Otherwise large command strings squish the
icons in column 1.
… none

If you use icon:none in the command array, the :first-child is the
command name text span. Setting flex-shrink: 0 on it makes it misbhave
and push the displayed hotkey away/not wrap command text etc.
@rouilj
Copy link
Contributor Author

rouilj commented Feb 7, 2023

Don't merge this. I am having a wierd issue where the output html is being shifted.

e.g. rather than

<p><svg><svg><span "command"><span><span "kyb"></span></p>

I see:

<p><span "command"><span><span "kyb"></span><svg><svg></p>

I have no idea what happens here. Sometimes the html is messed up on initial display, sometimes after a search and sometime continuing to search corrects the layout.

I'll reopen it if I can figure out what's happening here.

@rouilj rouilj closed this Feb 7, 2023
@rouilj rouilj reopened this Feb 7, 2023
@rouilj
Copy link
Contributor Author

rouilj commented Feb 7, 2023

Upgrading to [email protected] has fixed the issue for me.
Change:

35062ad

updates package.json.

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.

1 participant