Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add note option to ExamplesList [MDS-689] #718

Merged
merged 1 commit into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions assets/ds-moon-preset.js
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,7 @@ module.exports = {
]);
addVariant('not-last', '&:not(:last-child)');
addVariant('not-first', '&:not(:first-child)');
addVariant('empty', '&:empty');
}),
],
};
11 changes: 5 additions & 6 deletions lib/moon_web/components/example_and_code.ex
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ defmodule MoonWeb.Components.ExampleAndCode do
<div class="flex flex-row items-center justify-between">
<div class="flex flex-row gap-2 w-full">
<Tabs id={"#{@id}-example-and-code"} class="justify-between gap-6">
<h2 class="text-moon-24 font-semibold">{@title}</h2>
<Tabs.List class="w-fit p-1 gap-1 bg-goku rounded-moon-s-md">
<h2 class="text-moon-24 font-semibold order-1">{@title}</h2>
<p :if={slot_assigned?(:note)} class="text-moon-16 w-full order-3 empty:hidden"><#slot {@note} /></p>
<Tabs.List class="w-fit p-1 gap-1 bg-goku rounded-moon-s-md order-2">
<Tabs.Segment class="flex flex-row gap-2">
<ControlsEye class="text-moon-24" />
<span class="hidden md:block">Preview</span>
Expand All @@ -35,7 +36,7 @@ defmodule MoonWeb.Components.ExampleAndCode do
<span class="hidden md:block">Code</span>
</Tabs.Segment>
</Tabs.List>
<Tabs.Panels>
<Tabs.Panels class="order-4">
<Tabs.Panel>
<div class={merge([
"p-4 flex bg-goku text-moon-14 rounded-moon-s-sm w-full",
Expand All @@ -56,9 +57,7 @@ defmodule MoonWeb.Components.ExampleAndCode do
</Tabs>
</div>
</div>
<div class="text-moon-16" :if={slot_assigned?(:note)}>
<p><#slot {@note} /></p>
</div>

<div
class="theme-moon-dark grid gap-4 p-4 bg-goku text-moon-14 rounded-moon-s-sm"
:if={slot_assigned?(:state)}
Expand Down
1 change: 1 addition & 0 deletions lib/moon_web/components/examples_list.ex
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ defmodule MoonWeb.Components.ExamplesList do
~F"""
{#for module <- @examples}
<ExampleAndCode title={title(module)} id={"example-#{module}"}>
<:note>{(Kernel.function_exported?(module, :note, 0) && module.note()) || ""}</:note>
<:example><.moon {=module} id={"example-contents-#{module}"} /></:example>
<:code>{(Kernel.function_exported?(module, :code, 0) && module.code()) || ""}</:code>
</ExampleAndCode>
Expand Down
6 changes: 6 additions & 0 deletions lib/moon_web/examples/design/button_example/multi_line.ex
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ defmodule MoonWeb.Examples.Design.ButtonExample.MultiLine do
"""
end

def note() do
"""
Multiline button exists in XL size only. Please copy and paste the code below to see the result.
"""
end

def code() do
"""
alias Moon.Design.Button
Expand Down