Skip to content

Commit

Permalink
Update icon to use GitHub style
Browse files Browse the repository at this point in the history
  • Loading branch information
choldgraf committed Jun 22, 2021
1 parent f96e69b commit 79cc874
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 12 deletions.
5 changes: 5 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,10 @@
install_requires=["sphinx>=1.8"],
extras_require={
"code_style": ["pre-commit==2.12.1"],
"rtd": [
"sphinx",
"ipython",
"sphinx-book-theme",
],
},
)
6 changes: 3 additions & 3 deletions sphinx_copybutton/_static/copy-button.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 15 additions & 7 deletions sphinx_copybutton/_static/copybutton.css
Original file line number Diff line number Diff line change
@@ -1,32 +1,41 @@
/* Copy buttons */
button.copybtn {
position: absolute;
display: flex;
top: .3em;
right: .5em;
width: 1.7rem;
height: 1.7rem;
opacity: 0;
transition: opacity 0.3s, border .3s;
transition: opacity 0.3s, border .3s, background-color .3s;
user-select: none;
padding: 0;
border: none;
outline: none;
border-radius: 0.4em;
border: #e1e1e1 1px solid;
background-color: rgb(233, 233, 233);
}

button.copybtn img {
width: 100%;
padding: .05em;
}

div.highlight {
position: relative;
}

.highlight:hover button.copybtn {
opacity: .7;
opacity: 1;
}

.highlight button.copybtn:hover {
opacity: 1;
background-color: rgb(223, 223, 223);
}

.highlight button.copybtn:active {
background-color: rgb(187, 187, 187);
}

/**
Expand All @@ -46,11 +55,10 @@ div.highlight {
visibility: hidden;
position: absolute;
content: attr(data-tooltip);
padding: 2px;
top: 0;
left: -.2em;
padding: .2rem;
font-size: .8rem;
left: -.2rem;
background: grey;
font-size: 1rem;
color: white;
white-space: nowrap;
z-index: 2;
Expand Down
3 changes: 1 addition & 2 deletions sphinx_copybutton/_static/copybutton.js_t
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,9 @@ const addCopyButtonToCodeCells = () => {
codeCells.forEach((codeCell, index) => {
const id = codeCellId(index)
codeCell.setAttribute('id', id)
const pre_bg = getComputedStyle(codeCell).backgroundColor;

const clipboardButton = id =>
`<button class="copybtn o-tooltip--left" style="background-color: ${pre_bg}" data-tooltip="${messages[locale]['copy']}" data-clipboard-target="#${id}">
`<button class="copybtn o-tooltip--left" data-tooltip="${messages[locale]['copy']}" data-clipboard-target="#${id}">
<img src="${path_static}{{ copybutton_image_path }}" alt="${messages[locale]['copy_to_clipboard']}">
</button>`
codeCell.insertAdjacentHTML('afterend', clipboardButton(id))
Expand Down
41 changes: 41 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# To use tox, see https://tox.readthedocs.io
# Simply pip or conda install tox
# If you use conda, you may also want to install tox-conda
# then run `tox` or `tox -- {pytest args}`
# To run in parallel using `tox -p` (this does not appear to work for this repo)

# To rebuild the tox environment, for example when dependencies change, use
# `tox -r`

# Note: if the following error is encountered: `ImportError while loading conftest`
# then then deleting compiled files has been found to fix it: `find . -name \*.pyc -delete`

[tox]
envlist = py37-sphinx3

[testenv]
# only recreate the environment when we use `tox -r`
recreate = false

[testenv:docs-build]
description = Build the documentation and launch browser
extras =
rtd
commands =
sphinx-build \
-n -b {posargs:html} docs/ docs/_build/{posargs:html}

[testenv:docs-live]
description = Build the documentation and launch browser
deps =
sphinx-autobuild
sphinx-rtd-theme
alabaster
extras =
rtd
commands =
sphinx-autobuild \
--re-ignore _build/.* \
--watch sphinx_copybutton \
--port 0 --open-browser \
-n -b {posargs:html} docs/ docs/_build/{posargs:html}

0 comments on commit 79cc874

Please sign in to comment.