Skip to content

Commit a1a3fb2

Browse files
committed
Add great error messages cheatsheet
1 parent b0acfdb commit a1a3fb2

File tree

10 files changed

+52
-20
lines changed

10 files changed

+52
-20
lines changed

lib/components_guide_web.ex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ defmodule ComponentsGuideWeb do
107107
alias ComponentsGuideWeb.Router.Helpers, as: Routes
108108

109109
import Paredown
110+
import ComponentsGuideWeb.AssetsHelpers
110111
alias ComponentsGuideWeb.StylingHelpers, as: Styling
111112
alias ComponentsGuideWeb.FormattingHelpers, as: Format
112113

lib/components_guide_web/controllers/accessibility_first_controller.ex

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,18 +51,18 @@ defmodule ComponentsGuideWeb.AccessibilityFirstView do
5151
use ComponentsGuideWeb.Snippets
5252
use Phoenix.HTML
5353

54-
def collected_image(conn, image_name) do
55-
%{static_path: path_to_image, width: width, height: height} = render(image_name)
56-
url = Routes.static_path(conn, "/" <> path_to_image)
57-
tag(:img, src: url, width: width / 2, height: height / 2)
58-
end
59-
60-
def collected_figure(conn, image_name, caption) do
61-
content_tag(:figure, [
62-
collected_image(conn, image_name),
63-
content_tag(:figcaption, caption)
64-
])
65-
end
54+
# def collected_image(conn, image_name) do
55+
# %{static_path: path_to_image, width: width, height: height} = render(image_name)
56+
# url = Routes.static_path(conn, "/" <> path_to_image)
57+
# tag(:img, src: url, width: width / 2, height: height / 2)
58+
# end
59+
60+
# def collected_figure(conn, image_name, caption) do
61+
# content_tag(:figure, [
62+
# collected_image(conn, image_name),
63+
# content_tag(:figcaption, caption)
64+
# ])
65+
# end
6666

6767
def table_rows(rows_content) do
6868
Enum.map(rows_content, &table_row/1)

lib/components_guide_web/controllers/cheatsheets_controller.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ defmodule ComponentsGuideWeb.CheatsheetsController do
1414
render(conn, "index.html", article: "intro", wasm_constant: @wasm_constant)
1515
end
1616

17-
@articles ["rxjs"]
17+
@articles ["rxjs", "error-messages"]
1818

1919
def show(conn, %{"id" => article}) when article in @articles do
2020
render(conn, "index.html", article: article)

lib/components_guide_web/template_engines/markdown_engine.ex

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ defmodule ComponentsGuideWeb.TemplateEngines.MarkdownEngine do
4242
Regex.replace(regex, html, fn _whole, tag_suffix, image, content ->
4343
case tag_suffix do
4444
"figure" ->
45-
"<div><%= collected_figure(@conn, #{inspect(image)}, #{inspect(content)}) %></div>"
45+
# "<div><%= inspect(__MODULE__) %></div>"
46+
"<div><%= collected_figure(@conn, __MODULE__, #{inspect(image)}, #{inspect(content)}) %></div>"
4647

4748
_ ->
4849
"!" <> image <> "!" <> content
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<nav class="pt-6 pb-4">
22
<ul y-y x-x=md class="text-lg font-bold text-shadow" data-links="p-3">
33
<li><%= link("Intro", to: '/cheatsheets') %>
4+
<li><%= link("Error Messages", to: '/cheatsheets/error-messages') %>
45
<li><%= link("RxJS", to: '/cheatsheets/rxjs') %>
56
</ul>
67
</nav>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Great Error Messages
2+
3+
## Network issues
4+
5+
<collected-figure image="vscode-marketplace-offline">
6+
When I search in Visual Studio Code’s Marketplace and it was unable to fetch any data, we get an offline error message: “Unable to search the Marketplace when offline, please check your network connection.”
7+
</collected-figure>
24.3 KB
Loading

lib/components_guide_web/templates/react_typescript/testing.html.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ getByRole('img', { name: 'New document' });
327327
### Roles > Tag Names
328328

329329
<figure>
330-
<%= collected_image(@conn, "list-of-roles") %>
330+
<%= collected_image(@conn, view_module(@conn), "list-of-roles") %>
331331
<figcaption>
332332
<%= line("A list of roles [from the wai-aria spec](https://www.w3.org/TR/wai-aria/#widget_roles).") %>
333333
</figcaption>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
defmodule ComponentsGuideWeb.AssetsHelpers do
2+
@moduledoc """
3+
Conveniences for presenting assets like images
4+
"""
5+
6+
use Phoenix.HTML
7+
import Phoenix.View
8+
alias ComponentsGuideWeb.Router.Helpers, as: Routes
9+
10+
def collected_image(conn, module, image_name) do
11+
%{static_path: path_to_image, width: width, height: height} = module.render(image_name, [])
12+
url = Routes.static_path(conn, "/" <> path_to_image)
13+
tag(:img, src: url, width: width / 2, height: height / 2)
14+
end
15+
16+
def collected_figure(conn, module, image_name, caption) do
17+
content_tag(:figure, [
18+
collected_image(conn, module, image_name),
19+
content_tag(:figcaption, caption)
20+
])
21+
end
22+
end

lib/components_guide_web/views/react_typescript_view.ex

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ defmodule ComponentsGuideWeb.ReactTypescriptView do
2323
def article_content_class("editor-prolog"), do: "content text-xl"
2424
def article_content_class(_article), do: "prose md:prose-xl prose-invert max-w-4xl mx-auto py-16"
2525

26-
def collected_image(conn, name) do
27-
%{static_path: path_to_image, width: width, height: height} = render(name)
28-
url = Routes.static_path(conn, "/" <> path_to_image)
29-
tag(:img, src: url, width: width / 2, height: height / 2)
30-
end
26+
# def collected_image(conn, name) do
27+
# %{static_path: path_to_image, width: width, height: height} = render(name)
28+
# url = Routes.static_path(conn, "/" <> path_to_image)
29+
# tag(:img, src: url, width: width / 2, height: height / 2)
30+
# end
3131

3232
def table_rows(rows_content) do
3333
Enum.map(rows_content, &table_row/1)

0 commit comments

Comments
 (0)