-
Notifications
You must be signed in to change notification settings - Fork 292
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add CSS class support for box component (#995)
- Loading branch information
1 parent
429fa93
commit f60e66e
Showing
12 changed files
with
274 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import mesop as me | ||
|
||
|
||
@me.page( | ||
security_policy=me.SecurityPolicy( | ||
allowed_iframe_parents=["https://google.github.io"] | ||
), | ||
stylesheets=[ | ||
"https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css", | ||
], | ||
path="/bootstrap", | ||
) | ||
def page(): | ||
with me.box(classes="container"): | ||
with me.box( | ||
classes="d-flex flex-wrap justify-content-between py-3 mb-4 border-bottom", | ||
): | ||
with me.box( | ||
classes="d-flex align-items-center mb-3 mb-md-0 me-md-auto link-body-emphasis text-decoration-none fs-4", | ||
): | ||
me.text("Mesop") | ||
|
||
with me.box(classes="nav nav-pills"): | ||
with me.box(classes="nav-item"): | ||
with me.box(classes="nav-link active"): | ||
me.text("Features") | ||
with me.box(classes="nav-item"): | ||
with me.box(classes="nav-link"): | ||
me.text("About") | ||
|
||
with me.box(classes="container px-4 py-5"): | ||
with me.box(classes="pb-2 border-bottom"): | ||
me.text("Columns", type="headline-5") | ||
|
||
with me.box(classes="row g-4 py-5 row-cols-1 row-cols-lg-3"): | ||
with me.box(classes="feature col"): | ||
with me.box(classes="fs-2 text-body-emphasis"): | ||
me.text("Featured title") | ||
me.text( | ||
"Paragraph of text beneath the heading to explain the heading. We'll add onto it with another sentence and probably just keep going until we run out of words." | ||
) | ||
me.link(text="Call to action", url="/#") | ||
|
||
with me.box(classes="feature col"): | ||
with me.box(classes="fs-2 text-body-emphasis"): | ||
me.text("Featured title") | ||
me.text( | ||
"Paragraph of text beneath the heading to explain the heading. We'll add onto it with another sentence and probably just keep going until we run out of words." | ||
) | ||
me.link(text="Call to action", url="/#") | ||
|
||
with me.box(classes="feature col"): | ||
with me.box(classes="fs-2 text-body-emphasis"): | ||
me.text("Featured title") | ||
me.text( | ||
"Paragraph of text beneath the heading to explain the heading. We'll add onto it with another sentence and probably just keep going until we run out of words." | ||
) | ||
me.link(text="Call to action", url="/#") | ||
|
||
with me.box( | ||
classes="d-flex flex-wrap justify-content-between align-items-center py-3 my-4 border-top" | ||
): | ||
with me.box(classes="col-md-4 mb-0 text-body-secondary"): | ||
me.text("Copyright 2024 Mesop") | ||
|
||
with me.box(classes="nav col-md-4 justify-content-end"): | ||
with me.box(classes="nav-item"): | ||
with me.box(classes="nav-link px-2 text-body-secondary"): | ||
me.text("Home") | ||
with me.box(classes="nav-item"): | ||
with me.box(classes="nav-link px-2 text-body-secondary"): | ||
me.text("Features") | ||
with me.box(classes="nav-item"): | ||
with me.box(classes="nav-link px-2 text-body-secondary"): | ||
me.text("FAQs") | ||
with me.box(classes="nav-item"): | ||
with me.box(classes="nav-link px-2 text-body-secondary"): | ||
me.text("About") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
""" | ||
Example Tailwind command: | ||
``` | ||
npx tailwindcss -i ./tailwind_input.css -o ./tailwind.css | ||
``` | ||
Example Tailwind config: | ||
``` | ||
/** @type {import('tailwindcss').Config} */ | ||
module.exports = { | ||
content: ["main.py"], | ||
theme: { | ||
extend: {}, | ||
}, | ||
plugins: [], | ||
safelist: [], | ||
}; | ||
``` | ||
Original HTML mark up: | ||
``` | ||
<html> | ||
<body class="min-h-screen flex flex-col"> | ||
<!-- Header --> | ||
<header class="bg-gray-800 text-white py-4"> | ||
<div class="container mx-auto"> | ||
<h1 class="text-2xl font-bold">Header</h1> | ||
</div> | ||
</header> | ||
<!-- Main Content with Sidebar --> | ||
<div class="flex flex-1"> | ||
<!-- Sidebar --> | ||
<aside class="w-64 bg-gray-200 p-4"> | ||
<h2 class="text-lg font-semibold mb-4">Sidebar</h2> | ||
<ul> | ||
<li><a href="#" class="text-gray-700 block py-2">Link 1</a></li> | ||
<li><a href="#" class="text-gray-700 block py-2">Link 2</a></li> | ||
<li><a href="#" class="text-gray-700 block py-2">Link 3</a></li> | ||
</ul> | ||
</aside> | ||
<!-- Main Content --> | ||
<main class="flex-1 p-6 bg-gray-100"> | ||
<div class="grid grid-cols-1 md:grid-cols-3 gap-4"> | ||
<div class="bg-white p-6 rounded shadow"> | ||
<h2 class="text-xl font-bold mb-2">Box 1</h2> | ||
<p>This is the content for box 1.</p> | ||
</div> | ||
<div class="bg-white p-6 rounded shadow"> | ||
<h2 class="text-xl font-bold mb-2">Box 2</h2> | ||
<p>This is the content for box 2.</p> | ||
</div> | ||
<div class="bg-white p-6 rounded shadow"> | ||
<h2 class="text-xl font-bold mb-2">Box 3</h2> | ||
<p>This is the content for box 3.</p> | ||
</div> | ||
</div> | ||
</main> | ||
</div> | ||
<!-- Footer --> | ||
<footer class="bg-gray-800 text-white py-4"> | ||
<div class="container mx-auto"> | ||
<p>© 2024 Your Company</p> | ||
</div> | ||
</footer> | ||
</body> | ||
</html> | ||
``` | ||
""" | ||
|
||
import mesop as me | ||
|
||
|
||
@me.page( | ||
security_policy=me.SecurityPolicy( | ||
allowed_iframe_parents=["https://google.github.io"] | ||
), | ||
stylesheets=[ | ||
# Specify your Tailwind CSS URL here. | ||
# | ||
# For local testing, you can just launch a basic Python HTTP server: | ||
# python -m http.server 8000 | ||
"http://localhost:8000/assets/tailwind.css", | ||
], | ||
path="/tailwind", | ||
) | ||
def app(): | ||
with me.box(classes="min-h-screen flex flex-col"): | ||
with me.box(classes="bg-gray-800 text-white py-4"): | ||
with me.box(classes="container mx-auto"): | ||
with me.box(classes="text-2xl font-bold"): | ||
me.text("Header") | ||
|
||
with me.box(classes="flex flex-1"): | ||
with me.box(classes="w-64 bg-gray-200 p-4"): | ||
with me.box(classes="text-lg font-semibold mb-4"): | ||
me.text("Sidebar") | ||
with me.box(classes="text-gray-700 block py-2"): | ||
me.text("Link 1") | ||
with me.box(classes="text-gray-700 block py-2"): | ||
me.text("Link 2") | ||
with me.box(classes="text-gray-700 block py-2"): | ||
me.text("Link 3") | ||
|
||
with me.box(classes="flex-1 p-6 bg-gray-100"): | ||
with me.box(classes="grid grid-cols-1 md:grid-cols-3 gap-4"): | ||
with me.box(classes="bg-white p-6 rounded shadow"): | ||
with me.box(classes="text-xl font-bold mb-2"): | ||
me.text("Box 1") | ||
me.text("This is the content for box 1.") | ||
|
||
with me.box(classes="bg-white p-6 rounded shadow"): | ||
with me.box(classes="text-xl font-bold mb-2"): | ||
me.text("Box 2") | ||
me.text("This is the content for box 2") | ||
|
||
with me.box(classes="bg-white p-6 rounded shadow"): | ||
with me.box(classes="text-xl font-bold mb-2"): | ||
me.text("Box 3") | ||
me.text("This is the content for box 3") | ||
|
||
with me.box(classes="bg-gray-800 text-white py-4"): | ||
with me.box(classes="container mx-auto"): | ||
me.text("2024 Mesop") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
--default-bottom-panel-height: 400px; | ||
} | ||
|
||
.container { | ||
.me-container { | ||
height: 100%; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
.container { | ||
.me-container { | ||
height: 100%; | ||
} | ||
|
||
.content { | ||
.me-content { | ||
overflow: hidden; | ||
} | ||
|
||
|