|
| 1 | +# This file is used to create a minimal Bootstrap CSS file based on the Minty |
| 2 | +# Bootstwatch theme for use in the example apps. |
| 3 | + |
| 4 | +# NOTE: This script requires the `purgecss` package to be installed. |
| 5 | +# You can install it with `npm install -g purgecss`. |
| 6 | + |
| 7 | +import shutil |
| 8 | +import subprocess |
| 9 | +from pathlib import Path |
| 10 | + |
| 11 | +import shinyswatch |
| 12 | + |
| 13 | +from shiny import ui |
| 14 | + |
| 15 | +app_ui = ui.page_sidebar( |
| 16 | + ui.sidebar( |
| 17 | + ui.input_numeric("n", "N", min=0, max=100, value=20), |
| 18 | + title="Parameters", |
| 19 | + ), |
| 20 | + ui.h2("Output"), |
| 21 | + ui.output_text_verbatim("txt"), |
| 22 | + ui.markdown( |
| 23 | + """ |
| 24 | +**AI-generated filler text.** In the world of exotic fruits, the durian stands out with its spiky exterior and strong odor. Despite its divisive smell, many people are drawn to its rich, creamy texture and unique flavor profile. This tropical fruit is often referred to as the "king of fruits" in various Southeast Asian countries. |
| 25 | +
|
| 26 | +Durians are known for their large size and thorn-covered husk, which requires careful handling. The flesh inside can vary in color from pale yellow to deep orange, with a custard-like consistency that melts in your mouth. Some describe its taste as a mix of sweet, savory, and creamy, while others find it overpowering and pungent. |
| 27 | +""" |
| 28 | + ), |
| 29 | + shinyswatch.theme.minty, |
| 30 | + title="Theme Example", |
| 31 | +) |
| 32 | + |
| 33 | +# If __file__ is not defined, use the current working directory |
| 34 | +if not globals().get("__file__"): |
| 35 | + __file__ = Path.cwd() / "_purgecss.py" |
| 36 | + |
| 37 | +save_dir = Path(__file__).parent / "output" |
| 38 | +if save_dir.exists(): |
| 39 | + shutil.rmtree(save_dir) |
| 40 | +save_dir.mkdir() |
| 41 | +app_ui.save_html(save_dir / "index.html", include_version=False) |
| 42 | + |
| 43 | +purged_dir = Path(__file__).parent / "css" |
| 44 | +if purged_dir.exists(): |
| 45 | + shutil.rmtree(purged_dir) |
| 46 | +purged_dir.mkdir(exist_ok=True) |
| 47 | + |
| 48 | +args = [ |
| 49 | + "purgecss", |
| 50 | + "--css", |
| 51 | + "output/lib/shinyswatch-css/bootswatch.min.css", |
| 52 | + "--content", |
| 53 | + "output/index.html", |
| 54 | + "--output", |
| 55 | + "css", |
| 56 | +] |
| 57 | + |
| 58 | +subprocess.run(args) |
| 59 | + |
| 60 | +(purged_dir / "bootswatch.min.css").rename(purged_dir / "bootswatch-minty.min.css") |
| 61 | + |
| 62 | +if True: |
| 63 | + shutil.rmtree(save_dir) |
0 commit comments