Skip to content

Commit

Permalink
Add warning to guides and change styling of tip (#9075)
Browse files Browse the repository at this point in the history
* add warning and styling

* add changeset

* forward every trailing slash that vercel lets through

* fix weird tw thing

* fix error

* better fix for css trailing slash issue

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
  • Loading branch information
aliabd and gradio-pr-bot authored Aug 10, 2024
1 parent 7b288cf commit 3258968
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/cuddly-news-stare.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"website": minor
---

feat:Add warning to guides and change styling of tip
29 changes: 28 additions & 1 deletion js/_website/generate_jsons/src/guides/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,34 @@ def get_labeled_metadata(label, is_list=True):

guide_content = re.sub(
r"(\n\nTip: )(.*?)(?=\n\n|$)",
lambda x: f"<p class='tip'><strong>✍️ Tip:</strong> {x.group(2)}</p>",
lambda x: f"""
<p class='tip'>
<span class="inline-flex" style="align-items: baseline">
<svg class="self-center w-5 h-5 mx-1" xmlns="http://www.w3.org/2000/svg" width="800px" height="800px" viewBox="0 0 24 24" fill="currentColor">
<path fill-rule="evenodd" clip-rule="evenodd" d="M9.25 18.7089C9.25 18.2894 9.58579 17.9494 10 17.9494H14C14.4142 17.9494 14.75 18.2894 14.75 18.7089C14.75 19.1283 14.4142 19.4684 14 19.4684H10C9.58579 19.4684 9.25 19.1283 9.25 18.7089ZM9.91667 21.2405C9.91667 20.821 10.2525 20.481 10.6667 20.481H13.3333C13.7475 20.481 14.0833 20.821 14.0833 21.2405C14.0833 21.66 13.7475 22 13.3333 22H10.6667C10.2525 22 9.91667 21.66 9.91667 21.2405Z"/>
<path d="M7.41058 13.8283L8.51463 14.8807C8.82437 15.1759 9 15.5875 9 16.0182C9 16.6653 9.518 17.1899 10.157 17.1899H13.843C14.482 17.1899 15 16.6653 15 16.0182C15 15.5875 15.1756 15.1759 15.4854 14.8807L16.5894 13.8283C18.1306 12.3481 18.9912 10.4034 18.9999 8.3817L19 8.29678C19 4.84243 15.866 2 12 2C8.13401 2 5 4.84243 5 8.29678L5.00007 8.3817C5.00875 10.4034 5.86939 12.3481 7.41058 13.8283Z"/>
</svg>
<span><strong>Tip:</strong></span>
</span>
{x.group(2)}
</p>
""",
guide_content,
)

guide_content = re.sub(
r"(\n\nWarning: )(.*?)(?=\n\n|$)",
lambda x: f"""
<p class='warning'>
<span class="inline-flex" style="align-items: baseline">
<svg class="self-center w-5 h-5 mx-1" xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' fill='currentColor' version='1.1' width='800px' height='800px' viewBox='0 0 554.2 554.199' xml:space='preserve'>
<path d='M538.5,386.199L356.5,70.8c-16.4-28.4-46.7-45.9-79.501-45.9c-32.8,0-63.1,17.5-79.5,45.9L12.3,391.6 c-16.4,28.4-16.4,63.4,0,91.8C28.7,511.8,59,529.3,91.8,529.3H462.2c0.101,0,0.2,0,0.2,0c50.7,0,91.8-41.101,91.8-91.8 C554.2,418.5,548.4,400.8,538.5,386.199z M316.3,416.899c0,21.7-16.7,38.3-39.2,38.3s-39.2-16.6-39.2-38.3V416 c0-21.601,16.7-38.301,39.2-38.301S316.3,394.3,316.3,416V416.899z M317.2,158.7L297.8,328.1c-1.3,12.2-9.4,19.8-20.7,19.8 s-19.4-7.7-20.7-19.8L237,158.6c-1.3-13.1,5.801-23,18-23H299.1C311.3,135.7,318.5,145.6,317.2,158.7z'/>
</svg>
<span><strong>Warning:</strong></span>
</span>
{x.group(2)}
</p>
""",
guide_content,
)

Expand Down
24 changes: 20 additions & 4 deletions js/_website/src/lib/assets/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -225,19 +225,35 @@ code.language-bash {
}

.tip {
@apply bg-gradient-to-br from-orange-50 to-white border-orange-50 border-l-2 border-l-orange-300 text-orange-700 p-4 px-6;
@apply bg-gradient-to-br from-green-50 to-white border-green-50 border-l-2 border-l-green-300 text-green-700 p-4 px-6;
}

.tip strong {
@apply text-orange-700;
@apply text-green-700;
}

.tip code {
@apply text-orange-700;
@apply text-green-700;
}

.tip a {
@apply text-orange-700;
@apply text-green-700;
}

.warning {
@apply bg-gradient-to-br from-red-50 to-white border-red-50 border-l-2 border-l-red-300 text-red-700 p-4 px-6;
}

.warning strong {
@apply text-red-700;
}

.warning code {
@apply text-red-700;
}

.warning a {
@apply text-red-700;
}

.shared-link:before {
Expand Down
5 changes: 4 additions & 1 deletion js/_website/svelte.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,10 @@ const config = {
files: {
lib: "src/lib"
},
adapter: adapter()
adapter: adapter(),
paths: {
relative: false
}
}
};

Expand Down

0 comments on commit 3258968

Please sign in to comment.