Skip to content

Commit

Permalink
ran jlpm lint
Browse files Browse the repository at this point in the history
  • Loading branch information
parmentelat committed Nov 27, 2023
1 parent c734650 commit 457c455
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 43 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ pip uninstall jupyterlab_gridwidth

### Development install

***WARNING*** from this point on, this is the boilerplate text that comes with
**_WARNING_** from this point on, this is the boilerplate text that comes with
the extension cookie-cutter template; it is not guaranteed to be accurate

Note: You will need NodeJS to build the extension package.
Expand Down
49 changes: 33 additions & 16 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,30 @@

import { JupyterFrontEnd, JupyterFrontEndPlugin } from '@jupyterlab/application'
import { ICommandPalette } from '@jupyterlab/apputils'
import { INotebookTracker, } from '@jupyterlab/notebook'
import { INotebookTracker } from '@jupyterlab/notebook'
import { Cell } from '@jupyterlab/cells'

import { Scope, apply_on_cells } from 'jupyterlab-celltagsclasses'
import { md_toggle_multi, } from 'jupyterlab-celltagsclasses'
import { md_toggle_multi } from 'jupyterlab-celltagsclasses'

const PLUGIN_ID = 'jupyterlab-gridwidth:plugin'

const ALL_GRIDWIDTHS = [
'1-2', '1-3', '2-3', '1-4', '2-4', '3-4',
'1-5', '2-5', '3-5', '4-5',
'1-6', '2-6', '3-6', '4-6', '5-6',
'1-2',
'1-3',
'2-3',
'1-4',
'2-4',
'3-4',
'1-5',
'2-5',
'3-5',
'4-5',
'1-6',
'2-6',
'3-6',
'4-6',
'5-6'
]

const plugin: JupyterFrontEndPlugin<void> = {
Expand All @@ -28,24 +40,30 @@ const plugin: JupyterFrontEndPlugin<void> = {
activate: (
app: JupyterFrontEnd,
palette: ICommandPalette,
notebookTracker: INotebookTracker,
notebookTracker: INotebookTracker
) => {
console.log('extension jupyterlab-gridwidth is activating')

let command

// gridwidth-1-2..gridwidth-1-6
const ALL_GRIDWIDTHS_FULL = ALL_GRIDWIDTHS.map((gridwidth) => `gridwidth-${gridwidth}`)
const ALL_GRIDWIDTHS_FULL = ALL_GRIDWIDTHS.map(
gridwidth => `gridwidth-${gridwidth}`
)
for (const gridwidth of ALL_GRIDWIDTHS) {
const [num, den] = gridwidth.split('-')
command = `gridwidth:toggle-${num}-${den}`
app.commands.addCommand(command, {
label: `cell to take ${num}/${den} space (toggle)`,
execute: () => apply_on_cells(notebookTracker, Scope.Active,
(cell: Cell) => {
md_toggle_multi(cell, 'tags', `gridwidth-${gridwidth}`, ALL_GRIDWIDTHS_FULL)
}
)
execute: () =>
apply_on_cells(notebookTracker, Scope.Active, (cell: Cell) => {
md_toggle_multi(
cell,
'tags',
`gridwidth-${gridwidth}`,
ALL_GRIDWIDTHS_FULL
)
})
})
palette.addItem({ command, category: 'gridwidth' })
app.commands.addKeyBinding({
Expand All @@ -58,12 +76,11 @@ const plugin: JupyterFrontEndPlugin<void> = {
command = 'gridwidth:cancel'
app.commands.addCommand(command, {
label: 'cancel all gridwidths',
execute: () => apply_on_cells(notebookTracker, Scope.Active,
(cell: Cell) => {
execute: () =>
apply_on_cells(notebookTracker, Scope.Active, (cell: Cell) => {
console.log(`cancelling all gridwidths for cell ${cell.model.id}`)
md_toggle_multi(cell, 'tags', '', ALL_GRIDWIDTHS_FULL)
}
)
})
})
palette.addItem({ command, category: 'gridwidth' })
app.commands.addKeyBinding({
Expand Down
91 changes: 65 additions & 26 deletions style/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
border-radius: 3px;
}


.jp-Notebook {

& .cell-tag-level_basic {
background-color: #c7e8c7 !important;
border: 1px solid #040;
Expand Down Expand Up @@ -47,7 +45,6 @@
color: #a0a0a080;
}


/* hide only the input of cells with the tag 'hide-input' */
& .cell-tag-hide-input .jp-Cell-inputWrapper .jp-Cell-inputArea {
display: none;
Expand All @@ -57,37 +54,79 @@
display: none;
}


/* gridwidth-nn classes allow to use a fraction of the width */
.jp-WindowedPanel-window {
display: flex;
flex-direction: row;
flex-wrap: wrap;

& jp-Cell { min-width: 200px; }
& jp-Cell {
min-width: 200px;
}

& .jp-Cell.cell-tag-gridwidth-1-2 { width: 50%; }
& .jp-Cell.cell-tag-gridwidth-1-3 { width: 33.3%; }
& .jp-Cell.cell-tag-gridwidth-2-3 { width: 66.7%; }
& .jp-Cell.cell-tag-gridwidth-1-4 { width: 25%; }
& .jp-Cell.cell-tag-gridwidth-2-4 { width: 50%; } /* redundant */
& .jp-Cell.cell-tag-gridwidth-3-4 { width: 75%; }
& .jp-Cell.cell-tag-gridwidth-1-5 { width: 20%; }
& .jp-Cell.cell-tag-gridwidth-2-5 { width: 40%; }
& .jp-Cell.cell-tag-gridwidth-3-5 { width: 60%; }
& .jp-Cell.cell-tag-gridwidth-4-5 { width: 80%; }
& .jp-Cell.cell-tag-gridwidth-1-6 { width: 16.6%; }
& .jp-Cell.cell-tag-gridwidth-2-6 { width: 33.3%; } /* redundant */
& .jp-Cell.cell-tag-gridwidth-3-6 { width: 50%; } /* redundant */
& .jp-Cell.cell-tag-gridwidth-4-6 { width: 66.7%; } /* redundant */
& .jp-Cell.cell-tag-gridwidth-5-6 { width: 83.3%; }
& .jp-Cell.cell-tag-gridwidth-1-2 {
width: 50%;
}
& .jp-Cell.cell-tag-gridwidth-1-3 {
width: 33.3%;
}
& .jp-Cell.cell-tag-gridwidth-2-3 {
width: 66.7%;
}
& .jp-Cell.cell-tag-gridwidth-1-4 {
width: 25%;
}
& .jp-Cell.cell-tag-gridwidth-2-4 {
width: 50%;
} /* redundant */
& .jp-Cell.cell-tag-gridwidth-3-4 {
width: 75%;
}
& .jp-Cell.cell-tag-gridwidth-1-5 {
width: 20%;
}
& .jp-Cell.cell-tag-gridwidth-2-5 {
width: 40%;
}
& .jp-Cell.cell-tag-gridwidth-3-5 {
width: 60%;
}
& .jp-Cell.cell-tag-gridwidth-4-5 {
width: 80%;
}
& .jp-Cell.cell-tag-gridwidth-1-6 {
width: 16.6%;
}
& .jp-Cell.cell-tag-gridwidth-2-6 {
width: 33.3%;
} /* redundant */
& .jp-Cell.cell-tag-gridwidth-3-6 {
width: 50%;
} /* redundant */
& .jp-Cell.cell-tag-gridwidth-4-6 {
width: 66.7%;
} /* redundant */
& .jp-Cell.cell-tag-gridwidth-5-6 {
width: 83.3%;
}

& .jp-Cell:not(
.cell-tag-gridwidth-1-2,
.cell-tag-gridwidth-1-3, .cell-tag-gridwidth-2-3,
.cell-tag-gridwidth-1-4, .cell-tag-gridwidth-2-4, .cell-tag-gridwidth-3-4,
.cell-tag-gridwidth-1-5, .cell-tag-gridwidth-2-5, .cell-tag-gridwidth-3-5, .cell-tag-gridwidth-4-5,
.cell-tag-gridwidth-1-6, .cell-tag-gridwidth-2-6, .cell-tag-gridwidth-3-6, .cell-tag-gridwidth-4-6, .cell-tag-gridwidth-5-6
&
.jp-Cell:not(
.cell-tag-gridwidth-1-2,
.cell-tag-gridwidth-1-3,
.cell-tag-gridwidth-2-3,
.cell-tag-gridwidth-1-4,
.cell-tag-gridwidth-2-4,
.cell-tag-gridwidth-3-4,
.cell-tag-gridwidth-1-5,
.cell-tag-gridwidth-2-5,
.cell-tag-gridwidth-3-5,
.cell-tag-gridwidth-4-5,
.cell-tag-gridwidth-1-6,
.cell-tag-gridwidth-2-6,
.cell-tag-gridwidth-3-6,
.cell-tag-gridwidth-4-6,
.cell-tag-gridwidth-5-6
) {
width: 100%;
}
Expand Down

0 comments on commit 457c455

Please sign in to comment.