-
Notifications
You must be signed in to change notification settings - Fork 8
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
base: master
Are you sure you want to change the base?
Conversation
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.
Don't merge this. I am having a wierd issue where the output html is being shifted. e.g. rather than
I see:
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. |
Upgrading to [email protected] has fixed the issue for me. updates package.json. |
This adds support for placing icons to the left of the commands.
5 cases are supported:
if icon is not defined, it inserts an empty svg that holds 24px of space on the left of the label
if icon is null, the space is not held and the label smooshes to the left
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.
the icon can be an image, css sized to 24x24px.
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