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

Fix legacy support for icons-as-css-background #7947

Merged
merged 4 commits into from
Feb 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 9 additions & 3 deletions packages/application/src/shell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import { DocumentRegistry } from '@jupyterlab/docregistry';

import { DockPanelSvg, LabIcon } from '@jupyterlab/ui-components';
import { classes, DockPanelSvg, LabIcon } from '@jupyterlab/ui-components';

import { ArrayExt, find, IIterator, iter, toArray } from '@lumino/algorithm';

Expand Down Expand Up @@ -772,11 +772,14 @@ export class LabShell extends Widget implements JupyterFrontEnd.IShell {
// (for context menu support)
title.dataset = { ...title.dataset, id: widget.id };

// bind an appropriate style to the icon
if (title.icon instanceof LabIcon) {
// bind an appropriate style to the icon
title.icon = title.icon.bindprops({
stylesheet: 'mainAreaTab'
});
} else if (typeof title.icon === 'string' || !title.icon) {
// add some classes to help with displaying css background imgs
title.iconClass = classes(title.iconClass, 'jp-Icon');
}

dock.addWidget(widget, { mode, ref });
Expand Down Expand Up @@ -1182,11 +1185,14 @@ namespace Private {
// in order to dispatch click events to the right widget.
title.dataset = { id: widget.id };

// bind an appropriate style to the icon
if (title.icon instanceof LabIcon) {
// bind an appropriate style to the icon
title.icon = title.icon.bindprops({
stylesheet: 'sideBar'
});
} else if (typeof title.icon === 'string' || !title.icon) {
// add some classes to help with displaying css background imgs
title.iconClass = classes(title.iconClass, 'jp-Icon', 'jp-Icon-20');
}

this._refreshVisibility();
Expand Down
2 changes: 1 addition & 1 deletion packages/apputils/src/toolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ export function ToolbarButtonComponent(props: ToolbarButtonComponent.IProps) {
icon={props.icon}
iconClass={
// add some extra classes for proper support of icons-as-css-backgorund
classes(props.iconClass, 'jp-Icon', 'jp-Icon-16')
classes(props.iconClass, 'jp-Icon')
}
className="jp-ToolbarButtonComponent-icon"
tag="span"
Expand Down
3 changes: 2 additions & 1 deletion packages/filebrowser/src/listing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { Contents } from '@jupyterlab/services';
import {
caretDownIcon,
caretUpIcon,
classes,
fileIcon,
LabIcon
} from '@jupyterlab/ui-components';
Expand Down Expand Up @@ -1836,7 +1837,7 @@ export namespace DirListing {
// render the file item's icon
LabIcon.resolveElement({
icon: fileType?.icon,
iconClass: fileType?.iconClass,
iconClass: classes(fileType?.iconClass, 'jp-Icon'),
fallback: fileIcon,
container: iconContainer,
className: ITEM_ICON_CLASS,
Expand Down
6 changes: 3 additions & 3 deletions packages/launcher/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
VDomRenderer
} from '@jupyterlab/apputils';

import { LabIcon } from '@jupyterlab/ui-components';
import { classes, LabIcon } from '@jupyterlab/ui-components';

import {
ArrayExt,
Expand Down Expand Up @@ -205,7 +205,7 @@ export class Launcher extends VDomRenderer<LauncherModel> {
<div className="jp-Launcher-sectionHeader">
<LabIcon.resolveReact
icon={icon}
iconClass={iconClass}
iconClass={classes(iconClass, 'jp-Icon-cover')}
stylesheet="launcherSection"
/>
<h2 className="jp-Launcher-sectionTitle">{cat}</h2>
Expand Down Expand Up @@ -432,7 +432,7 @@ function Card(
) : (
<LabIcon.resolveReact
icon={icon}
iconClass={iconClass}
iconClass={classes(iconClass, 'jp-Icon-cover')}
stylesheet="launcherCard"
/>
)}
Expand Down
4 changes: 2 additions & 2 deletions packages/settingeditor/src/pluginlist.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import { ISettingRegistry } from '@jupyterlab/settingregistry';

import { LabIcon, settingsIcon } from '@jupyterlab/ui-components';
import { classes, LabIcon, settingsIcon } from '@jupyterlab/ui-components';

import { Message } from '@lumino/messaging';

Expand Down Expand Up @@ -278,7 +278,7 @@ namespace Private {
>
<LabIcon.resolveReact
icon={icon}
iconClass={iconClass}
iconClass={iconClass && classes(iconClass, 'jp-Icon')}
fallback={settingsIcon}
title={iconTitle}
tag="span"
Expand Down
2 changes: 1 addition & 1 deletion packages/settingregistry/src/plugin-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"jupyter.lab.setting-deprecated": { "type": "boolean", "default": false },
"jupyter.lab.setting-icon": {
"type": "string",
"default": "ui-components:settings"
"default": ""
},
"jupyter.lab.setting-icon-class": {
"type": "string",
Expand Down
2 changes: 1 addition & 1 deletion packages/ui-components/src/blueprint.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export const InputGroup = (props: IInputGroupProps & CommonProps<any>) => {
className={classes(props.className, 'jp-InputGroup')}
rightElement={
<div className="jp-InputGroupAction">
<BPIcon className={'jp-Icon'} icon={props.rightIcon} />
<BPIcon className={'jp-BPIcon'} icon={props.rightIcon} />
</div>
}
/>
Expand Down
5 changes: 4 additions & 1 deletion packages/ui-components/src/icon/widgets/menusvg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,10 @@ export namespace MenuSvg {

/* <DEPRECATED> */
if (typeof data.item.icon === 'string') {
return h.div({ className }, data.item.iconLabel);
return h.div(
{ className: classes(className, 'jp-Icon') },
data.item.iconLabel
);
}
/* </DEPRECATED> */

Expand Down
7 changes: 5 additions & 2 deletions packages/ui-components/src/style/icon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,8 @@ export namespace LabIconStyle {

launcherCard: {
container: {
height: '68px'
height: '52px',
width: '52px'
},
element: {
height: '52px',
Expand All @@ -224,7 +225,9 @@ export namespace LabIconStyle {
launcherSection: {
container: {
boxSizing: 'border-box',
marginRight: '12px'
marginRight: '12px',
height: '32px',
width: '32px'
},
element: {
height: '32px',
Expand Down
11 changes: 9 additions & 2 deletions packages/ui-components/style/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,15 @@ input::placeholder {
color: var(--jp-ui-font-color3);
}

.jp-Icon {
color: var(--jp-layout-color4);
.jp-BPIcon {
display: inline-block;
vertical-align: middle;
margin: auto;
}

/* Stop blueprint futzing with our icon fills */
.bp3-icon.jp-BPIcon > svg:not([fill]) {
fill: var(--jp-inverse-layout-color3);
}

.jp-InputGroupAction {
Expand Down
37 changes: 37 additions & 0 deletions packages/ui-components/style/deprecatedExtra.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,40 @@
:root {
--jp-icon-search-white: url('deprecated/search-white.svg');
}

.jp-Icon,
.jp-MaterialIcon {
background-position: center;
background-repeat: no-repeat;
background-size: 16px;
min-width: 16px;
min-height: 16px;
}

.jp-Icon-cover {
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}

/**
* (DEPRECATED) Support for specific CSS icon sizes
*/

.jp-Icon-16 {
background-size: 16px;
min-width: 16px;
min-height: 16px;
}

.jp-Icon-18 {
background-size: 18px;
min-width: 18px;
min-height: 18px;
}

.jp-Icon-20 {
background-size: 20px;
min-width: 20px;
min-height: 20px;
}
39 changes: 1 addition & 38 deletions packages/ui-components/style/icons.css
Original file line number Diff line number Diff line change
Expand Up @@ -270,44 +270,7 @@
--jp-warn-color0: var(--md-orange-700);
}

/**
* (DEPRECATED) Support for icons as CSS `background-images`
*/
.jp-MaterialIcon {
min-width: 16px;
min-height: 16px;
background-size: 16px;
display: inline-block;
vertical-align: middle;
background-repeat: no-repeat;
background-position: center;
}
.jp-Icon {
display: inline-block;
vertical-align: middle;
background-repeat: no-repeat;
background-position: center;
margin: auto;
}

.jp-Icon-16 {
min-width: 16px;
min-height: 16px;
background-size: 16px;
}

.jp-Icon-18 {
min-width: 18px;
min-height: 18px;
background-size: 18px;
}

.jp-Icon-20 {
min-width: 20px;
min-height: 20px;
background-size: 20px;
}

/* not sure what to do with this one, used in filebrowser listing */
.jp-DragIcon {
margin-right: 4px;
}