Skip to content

Commit 10b18ce

Browse files
committed
Remove dependency on notebook LESS
ship some of flexbox, mixins
1 parent bac2c03 commit 10b18ce

File tree

5 files changed

+123
-61
lines changed

5 files changed

+123
-61
lines changed

build_css.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,7 @@ function run(cmd) {
2323
}
2424

2525
run(['lessc',
26-
'--include-path=' + [
27-
'./less_include/notebook/notebook/static',
28-
'./less_include',
29-
].join(path.delimiter),
26+
'--include-path=./less_include',
3027
source,
3128
css_destination,
3229
]);
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
2+
/* Flexible box model classes */
3+
/* Taken from Alex Russell http://infrequently.org/2009/08/css-3-progress/ */
4+
5+
/* This file is a compatability layer. It allows the usage of flexible box
6+
model layouts accross multiple browsers, including older browsers. The newest,
7+
universal implementation of the flexible box model is used when available (see
8+
`Modern browsers` comments below). Browsers that are known to implement this
9+
new spec completely include:
10+
11+
Firefox 28.0+
12+
Chrome 29.0+
13+
Internet Explorer 11+
14+
Opera 17.0+
15+
16+
Browsers not listed, including Safari, are supported via the styling under the
17+
`Old browsers` comments below.
18+
*/
19+
20+
21+
.hbox() {
22+
/* Old browsers */
23+
display: -webkit-box;
24+
-webkit-box-orient: horizontal;
25+
-webkit-box-align: stretch;
26+
27+
display: -moz-box;
28+
-moz-box-orient: horizontal;
29+
-moz-box-align: stretch;
30+
31+
display: box;
32+
box-orient: horizontal;
33+
box-align: stretch;
34+
35+
/* Modern browsers */
36+
display: flex;
37+
flex-direction: row;
38+
align-items: stretch;
39+
}
40+
41+
.vbox() {
42+
/* Old browsers */
43+
display: -webkit-box;
44+
-webkit-box-orient: vertical;
45+
-webkit-box-align: stretch;
46+
47+
display: -moz-box;
48+
-moz-box-orient: vertical;
49+
-moz-box-align: stretch;
50+
51+
display: box;
52+
box-orient: vertical;
53+
box-align: stretch;
54+
55+
/* Modern browsers */
56+
display: flex;
57+
flex-direction: column;
58+
align-items: stretch;
59+
}
60+
61+
.box-flex0() {
62+
/* Old browsers */
63+
-webkit-box-flex: 0;
64+
-moz-box-flex: 0;
65+
box-flex: 0;
66+
67+
/* Modern browsers */
68+
flex: none;
69+
width: auto;
70+
}
71+
72+
.box-flex1() {
73+
/* Old browsers */
74+
-webkit-box-flex: 1;
75+
-moz-box-flex: 1;
76+
box-flex: 1;
77+
78+
/* Modern browsers */
79+
flex: 1;
80+
}
81+
82+
.box-flex() {
83+
/* Old browsers */
84+
.box-flex1();
85+
}
86+
87+
.box-flex2() {
88+
/* Old browsers */
89+
-webkit-box-flex: 2;
90+
-moz-box-flex: 2;
91+
box-flex: 2;
92+
93+
/* Modern browsers */
94+
flex: 2;
95+
}
96+
97+
.align-start() {
98+
/* Old browsers */
99+
-webkit-box-align: start;
100+
-moz-box-align: start;
101+
box-align: start;
102+
103+
/* Modern browsers */
104+
align-items: flex-start;
105+
}
106+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Mixin CSS classes
2+
3+
.border-box-sizing() {
4+
box-sizing: border-box;
5+
-moz-box-sizing: border-box;
6+
-webkit-box-sizing: border-box;
7+
}
8+
9+
.corner-all() {
10+
border-radius: @border-radius-base;
11+
}
12+

ipywidgets/static/widgets/less/widgets.less

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,9 @@
66
@import "/components/font-awesome/less/variables.less";
77

88
// import variables, mixins from Notebook
9-
@import "/base/less/variables.less";
10-
@import "/base/less/mixins.less";
11-
@import "/base/less/flexbox.less";
12-
13-
@import "/notebook/less/variables.less";
9+
// layout mixins
10+
@import "./flexbox.less";
11+
@import "./mixins.less";
1412

1513
@widget-width: 350px;
1614
@widget-width-short: 150px;
@@ -58,7 +56,6 @@
5856
content: @fa-var-chain-broken;
5957
font-family: 'FontAwesome';
6058
color: @brand-danger;
61-
font-size: @notebook_font_size;
6259
top: 3px;
6360
padding: 3px;
6461
}
@@ -133,7 +130,6 @@
133130
.ui-slider-range {
134131
height : 12px;
135132
margin-top : -4px;
136-
background : @page-backdrop-color;
137133
}
138134
}
139135
}
@@ -178,7 +174,6 @@
178174
.ui-slider-range {
179175
width : 12px;
180176
margin-left : -1px;
181-
background : @page-backdrop-color;
182177
}
183178
}
184179
}

setup.py

Lines changed: 1 addition & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,14 @@
2727
# get on with it
2828
#-----------------------------------------------------------------------------
2929

30-
import errno
3130
import os
32-
import shutil
3331
from distutils import log
3432
from distutils.core import setup, Command
3533
from distutils.command.build_py import build_py
3634
from distutils.command.sdist import sdist
3735
from glob import glob
3836
from os.path import join as pjoin
3937
from subprocess import check_call
40-
from zipfile import ZipFile
41-
42-
try:
43-
from urllib.request import urlopen
44-
except ImportError:
45-
from urllib2 import urlopen
4638

4739

4840
repo_root = os.path.dirname(os.path.abspath(__file__))
@@ -149,52 +141,14 @@ def run(self):
149141
update_package_data(self.distribution)
150142
return DecoratedCommand
151143

144+
152145
def update_package_data(distribution):
153146
"""update package_data to catch changes during setup"""
154147
build_py = distribution.get_command_obj('build_py')
155148
# distribution.package_data = find_package_data()
156149
# re-init build_py options which load package_data
157150
build_py.finalize_options()
158151

159-
class FetchNotebook(Command):
160-
description = "Fetch Notebook source, needed for LESS sources"
161-
162-
user_options = []
163-
164-
def initialize_options(self):
165-
pass
166-
167-
def finalize_options(self):
168-
pass
169-
170-
# FIXME: update url to 4.0 when notebook is released
171-
url = "https://github.com/jupyter/notebook/archive/master.zip"
172-
173-
def run(self):
174-
nb_dir = pjoin('less_include', 'notebook')
175-
nb_zip = pjoin('less_include', 'notebook.zip')
176-
if os.path.exists(nb_dir):
177-
return
178-
try:
179-
os.mkdir('less_include')
180-
except OSError as e:
181-
if e.errno != errno.EEXIST:
182-
raise
183-
if not os.path.exists(nb_zip):
184-
log.info("downloading %s" % self.url)
185-
r = urlopen(self.url)
186-
with open(nb_zip, 'wb') as f:
187-
for chunk in r:
188-
f.write(chunk)
189-
log.info("unzipping notebook")
190-
zf = ZipFile(nb_zip)
191-
if os.path.exists('notebook-tmp'):
192-
shutil.rmtree('notebook-tmp')
193-
zf.extractall('notebook-tmp')
194-
d = glob(pjoin('notebook-tmp', '*'))[0]
195-
shutil.move(d, nb_dir)
196-
os.rmdir('notebook-tmp')
197-
198152

199153
class NPM(Command):
200154
description = "install package,json dependencies using npm"
@@ -223,7 +177,6 @@ def should_run_npm(self):
223177
return mtime(self.node_modules) < mtime(pjoin(repo_root, 'package.json'))
224178

225179
def run(self):
226-
self.distribution.run_command('fetch_notebook')
227180
if self.should_run_npm():
228181
print("installing build dependencies with npm")
229182
check_call(['npm', 'install'], cwd=repo_root)
@@ -286,7 +239,6 @@ def run(self):
286239
'build_py': js_prerelease(build_py),
287240
'sdist': js_prerelease(sdist, strict=True),
288241
'jsdeps': NPM,
289-
'fetch_notebook': FetchNotebook,
290242
},
291243
)
292244

0 commit comments

Comments
 (0)