Skip to content
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commit 461b30f

Browse files
committed
refactor(editor): unorder_list done
1 parent 7729bac commit 461b30f

File tree

5 files changed

+213
-114
lines changed

5 files changed

+213
-114
lines changed

lib/helper/converter/editor_to_html/class.ex

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,13 @@ defmodule Helper.Converter.EditorToHTML.Class do
2424
# list
2525
"list" => %{
2626
"wrapper" => "list-wrapper",
27-
"item" => "list-item",
2827
"label" => "list-label",
2928
"label__default" => "list-label__default",
3029
"label__red" => "list-label__red",
3130
"label__green" => "list-label__green",
3231
"label__warn" => "list-label__warn",
32+
"unorder_list_prefix" => "list__item-unorder-prefix",
33+
"list_item" => "list-item",
3334
"checklist_item" => "list-checklist__item",
3435
"checklist_checkbox" => "checklist__item-checkbox",
3536
"checklist_checkbox_checked" => "checklist__item-check-sign-checked",

lib/helper/converter/editor_to_html/frags/list.ex

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,27 @@ defmodule Helper.Converter.EditorToHTML.Frags.List do
99

1010
@class get_in(Class.article(), ["list"])
1111

12+
def get_item(:unorder_list, %{
13+
"hideLabel" => hide_label,
14+
"indent" => indent,
15+
"label" => label,
16+
"labelType" => label_type,
17+
"text" => text
18+
}) do
19+
prefix_frag = frag(:unorder_list_prefix)
20+
label_frag = if hide_label, do: "", else: frag(:label, label_type, indent, label)
21+
text_frag = frag(:text, text)
22+
23+
item_class = @class["list_item"]
24+
indent_class = @class["indent_#{indent}"]
25+
26+
~s(<div class="#{item_class} #{indent_class}">
27+
#{prefix_frag}
28+
#{label_frag}
29+
#{text_frag}
30+
</div>)
31+
end
32+
1233
def get_item(:checklist, %{
1334
"checked" => checked,
1435
"hideLabel" => hide_label,
@@ -32,6 +53,12 @@ defmodule Helper.Converter.EditorToHTML.Frags.List do
3253
</div>)
3354
end
3455

56+
def frag(:unorder_list_prefix) do
57+
unorder_list_prefix_class = @class["unorder_list_prefix"]
58+
59+
~s(<div class="#{unorder_list_prefix_class}"></div>)
60+
end
61+
3562
def frag(:label, label_type, indent, label) do
3663
label_class = @class["label"]
3764
label_type_class = @class["label__#{label_type}"]
@@ -42,7 +69,7 @@ defmodule Helper.Converter.EditorToHTML.Frags.List do
4269
end
4370

4471
@spec frag(:checkbox, Boolean.t()) :: T.html()
45-
def frag(:checkbox, checked) do
72+
def frag(:checkbox, checked) when is_boolean(checked) do
4673
checked_svg = svg(:checked)
4774

4875
checkbox_class = @class["checklist_checkbox"]
@@ -56,7 +83,8 @@ defmodule Helper.Converter.EditorToHTML.Frags.List do
5683
</div>)
5784
end
5885

59-
def frag(:text, text) do
86+
@spec frag(:text, String.t()) :: T.html()
87+
def frag(:text, text) when is_binary(text) do
6088
text_class = @class["text"]
6189

6290
~s(<div class="#{text_class}">

lib/helper/converter/editor_to_html/frontend_test/script.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/helper/converter/editor_to_html/frontend_test/styles.css

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,33 @@ body {
2727
padding: 1.2em 0;
2828
}
2929

30+
.article-viewer-wrapper .list-wrapper .list-item {
31+
display: flex;
32+
align-items: baseline;
33+
box-sizing: content-box;
34+
position: relative;
35+
width: 100%;
36+
}
37+
38+
.article-viewer-wrapper .list-wrapper .list-item .list__item-unorder-prefix {
39+
position: relative;
40+
margin-right: 26px;
41+
}
42+
43+
.article-viewer-wrapper
44+
.list-wrapper
45+
.list-item
46+
.list__item-unorder-prefix::before {
47+
content: "";
48+
position: absolute;
49+
width: 6px;
50+
height: 6px;
51+
background: #09aac1;
52+
border-radius: 50%;
53+
top: -8px;
54+
left: 0;
55+
}
56+
3057
.article-viewer-wrapper .list-wrapper .list-checklist__item {
3158
display: flex;
3259
align-items: baseline;
@@ -131,6 +158,7 @@ body {
131158
color: #eea564;
132159
}
133160

161+
.article-viewer-wrapper .list-wrapper .list-item-text,
134162
.article-viewer-wrapper .list-wrapper .list-checklist__item-text {
135163
outline: none;
136164
flex-grow: 1;

0 commit comments

Comments
 (0)