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

Lateral cells layout flag #413

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
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 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,10 @@ pip install --upgrade jupyterthemes
```
jt [-h] [-l] [-t THEME] [-f MONOFONT] [-fs MONOSIZE] [-nf NBFONT]
[-nfs NBFONTSIZE] [-tf TCFONT] [-tfs TCFONTSIZE] [-dfs DFFONTSIZE]
[-m MARGINS] [-cursw CURSORWIDTH] [-cursc CURSORCOLOR] [-vim]
[-cellw CELLWIDTH] [-lineh LINEHEIGHT] [-altp] [-altmd] [-altout]
[-P] [-T] [-N] [-r] [-dfonts]
[-ofs OUTFONTSIZE] [-mathfs MATHFONTSIZE] [-m MARGINS]
[-cursw CURSORWIDTH] [-cursc CURSORCOLOR] [-cellw CELLWIDTH]
[-lineh LINEHEIGHT] [-altp] [-altmd] [-altout] [-P] [-T] [-N] [-kl]
[-lc] [-iccw INPUTCODECELLWIDTH] [-vim] [-r] [-dfonts]
```

#### Description of Command Line options
Expand Down Expand Up @@ -97,6 +98,8 @@ jt [-h] [-l] [-t THEME] [-f MONOFONT] [-fs MONOSIZE] [-nf NBFONT]
| Toolbar Visible | -T | -- |
| Name & Logo Visible | -N | -- |
| Kernel Logo Visible | -kl | -- |
| Lateral Cells | -lc | -- |
| Input Code-Cell Width | -iccw | 50% |
| Reset Default Theme | -r | -- |
| Force Default Fonts | -dfonts | -- |

Expand Down Expand Up @@ -152,6 +155,9 @@ jt -t oceans16 -cursc r -cursw 5
# choose alternate prompt layout (narrower/no numbers)
jt -t grade3 -altp

# setup lateral cell layout, with input-cells being 55% of the cell-width, which is 90% of the window
jt -t solarizedl -lc -iccw 55% -cellw 90%

# my two go-to styles
# dark
jt -t onedork -fs 95 -altp -tfs 11 -nfs 115 -cellw 88% -T
Expand Down
24 changes: 21 additions & 3 deletions jupyterthemes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ def install_theme(theme=None,
toolbar=False,
nbname=False,
kernellogo=False,
dfonts=False):
dfonts=False,
lateralcells=True,
inputcodecellwidth="50%"):

""" Install theme to jupyter_customcss with specified font, fontsize,
md layout, and toolbar pref
Expand Down Expand Up @@ -97,7 +99,9 @@ def install_theme(theme=None,
vimext=vimext,
toolbar=toolbar,
nbname=nbname,
kernellogo=kernellogo)
kernellogo=kernellogo,
lateralcells=lateralcells,
inputcodecellwidth=inputcodecellwidth)

# compile tempfile.less to css code and append to style_css
style_css = stylefx.less_to_css(style_less)
Expand Down Expand Up @@ -250,6 +254,18 @@ def main():
action='store_true',
default=False,
help="kernel logo visible")
parser.add_argument(
'-lc',
"--lateralcells",
action='store_true',
default=False,
help="switch vertical cell layout off")
parser.add_argument(
'-iccw',
"--inputcodecellwidth",
action='store',
default='50%',
help="the width of the input code-cell (only with -lc): as a %% it is relative to -cellwidth")
parser.add_argument(
'-vim',
"--vimext",
Expand Down Expand Up @@ -311,4 +327,6 @@ def main():
toolbar=args.toolbar,
nbname=args.nbname,
kernellogo=args.kernellogo,
dfonts=args.defaultfonts)
dfonts=args.defaultfonts,
lateralcells=args.lateralcells,
inputcodecellwidth=args.inputcodecellwidth)
8 changes: 8 additions & 0 deletions jupyterthemes/layout/cells.less
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,14 @@ div.cell.text_cell.selected.jupyter-soft-selected:before {
border-color: @tc-border-selected !important;
}

div.code_cell {
display: flex;
flex-direction: @code-cell-direction;
}

div.cell.code_cell .input {
width : @code-cell-input-width;
min-width : @code-cell-input-width;
border-left: 5px solid @cc-input-bg !important;
border-radius: 3px;
border-bottom-left-radius: 3px;
Expand Down Expand Up @@ -242,6 +249,7 @@ div.cell.code_cell.rendered.unselected.jupyter-soft-selected .run_this_cell:hove

/********** CODE CELL OUTPUT AREA **********/
div.output_wrapper {
width: 100%;
background-color: @cc-output-bg;
border: 0px;
left: 0px;
Expand Down
1 change: 1 addition & 0 deletions jupyterthemes/layout/codemirror.less
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ div.tooltiptext.bigtooltip {
border-radius: 2px;
font-style: normal;
font-weight: normal;
padding-right: 1em;
}
.cm-s-ipython div.CodeMirror-selected {
background: @cm-selected;
Expand Down
4 changes: 3 additions & 1 deletion jupyterthemes/layout/extras.less
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,9 @@ div#short-key-bindings-intro.well, .well {
height: 22px;
line-height: 22px;
}

div.inner_cell{
justify-content: center;
}
/**************************************************/
/************** PAGER DOCUMENTATION ***************/
/**************************************************/
Expand Down
19 changes: 17 additions & 2 deletions jupyterthemes/stylefx.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,9 @@ def style_layout(style_less,
altprompt=False,
altmd=False,
altout=False,
hideprompt=False):
hideprompt=False,
lateralcells=False,
inputcodecellwidth="50%"):
"""Set general layout and style properties of text and code cells"""

# write theme name to ~/.jupyter/custom/ (referenced by jtplot.py)
Expand All @@ -256,7 +258,7 @@ def style_layout(style_less,
promptBorder = '2px solid @prompt-line'
tcPromptBorder = '2px solid @tc-prompt-std'
promptMinWidth = 11.5
outpromptMinWidth = promptMinWidth +.5 # remove + 3 since it will overlay output print() text
outpromptMinWidth = promptMinWidth + (-8 if lateralcells else .5) # remove + 3 since it will overlay output print() text
tcPromptWidth = promptMinWidth + .5
tcPromptFontsize = "@prompt-fontsize"
ccOutputBG = '@cc-output-bg-default'
Expand All @@ -279,6 +281,8 @@ def style_layout(style_less,
margins = '{}px'.format(margins)
if '%' not in cellwidth:
cellwidth = str(cellwidth) + 'px'
if '%' not in inputcodecellwidth:
inputcodecellwidth = str(inputcodecellwidth) + 'px'

style_less += '@container-margins: {};\n'.format(margins)
style_less += '@cell-width: {}; \n'.format(cellwidth)
Expand All @@ -298,6 +302,17 @@ def style_layout(style_less,
style_less += '@cursor-info: @cursor-width solid {}; \n'.format(
cursorcolor)
style_less += '@tc-prompt-fontsize: {}; \n'.format(tcPromptFontsize)
style_less += '@code-cell-direction: {}; \n'.format('row'
if lateralcells else 'column')
style_less += '@code-cell-input-width: {}; \n'.format(inputcodecellwidth
if lateralcells else '100%')
style_less += '@selected-prompt-right-border-width: {}px; \n'.format(0)
style_less += '@@selected-prompt-right-border-radius: {}px; \n'.format(0)
style_less += '@selected-prompt-left-border-width: {}px; \n'.format(5)
style_less += '@@selected-prompt-left-border-radius: {}px; \n'.format(3)
style_less += '@code-cell-border-left-width: {}px; \n'.format(5)
style_less += '@code-cell-border-radius: {}px; \n'.format(3)

style_less += '\n\n'

# read-in notebook.less (general nb style)
Expand Down