Skip to content

Commit 2a300ed

Browse files
committed
clean up style specs and types
1 parent b0cb5fc commit 2a300ed

File tree

1 file changed

+39
-20
lines changed

1 file changed

+39
-20
lines changed

lib/scenic/primitive/style/style.ex

Lines changed: 39 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -52,44 +52,60 @@ defmodule Scenic.Primitive.Style do
5252

5353
# import IEx
5454

55-
@type t :: %{atom => any}
55+
@type t :: %{
56+
[
57+
:cap
58+
| :fill
59+
| :font
60+
| :font_size
61+
| :hidden
62+
| :input
63+
| :join
64+
| :line_height
65+
| :miter_limit
66+
| :scissor
67+
| :stroke
68+
| :text_align
69+
| :text_base
70+
| :theme
71+
] => any
72+
}
5673

5774
@opts_map %{
58-
:input => Style.Input,
59-
:hidden => Style.Hidden,
60-
:texture_wrap => Style.TextureWrap,
61-
:texture_filter => Style.TextureFilter,
75+
:cap => Style.Cap,
6276
:fill => Style.Fill,
63-
:stroke => Style.Stroke,
77+
:font => Style.Font,
78+
:font_size => Style.FontSize,
79+
:hidden => Style.Hidden,
80+
:input => Style.Input,
6481
:join => Style.Join,
65-
:cap => Style.Cap,
6682
:line_height => Style.LineHeight,
6783
:miter_limit => Style.MiterLimit,
68-
:font => Style.Font,
69-
:font_blur => Style.FontBlur,
70-
:font_size => Style.FontSize,
84+
:scissor => Style.Scissor,
85+
:stroke => Style.Stroke,
7186
:text_align => Style.TextAlign,
7287
:text_base => Style.TextBase,
73-
# :text_height => Style.TextHeight,
74-
:scissor => Style.Scissor,
7588
:theme => Style.Theme
7689
}
7790

91+
@valid_styles @opts_map
92+
|> Enum.map(fn {k, _v} -> k end)
93+
|> Enum.sort()
94+
7895
@opts_schema [
79-
input: [type: {:custom, Style.Input, :validate, []}],
80-
hidden: [type: {:custom, Style.Hidden, :validate, []}],
96+
cap: [type: {:custom, Style.Cap, :validate, []}],
8197
fill: [type: {:custom, Style.Fill, :validate, []}],
82-
stroke: [type: {:custom, Style.Stroke, :validate, []}],
98+
font: [type: {:custom, Style.Font, :validate, []}],
99+
font_size: [type: {:custom, Style.FontSize, :validate, []}],
100+
hidden: [type: {:custom, Style.Hidden, :validate, []}],
101+
input: [type: {:custom, Style.Input, :validate, []}],
83102
join: [type: {:custom, Style.Join, :validate, []}],
84-
cap: [type: {:custom, Style.Cap, :validate, []}],
85103
line_height: [type: {:custom, Style.LineHeight, :validate, []}],
86104
miter_limit: [type: {:custom, Style.MiterLimit, :validate, []}],
87-
font: [type: {:custom, Style.Font, :validate, []}],
88-
font_size: [type: {:custom, Style.FontSize, :validate, []}],
105+
scissor: [type: {:custom, Style.Scissor, :validate, []}],
106+
stroke: [type: {:custom, Style.Stroke, :validate, []}],
89107
text_align: [type: {:custom, Style.TextAlign, :validate, []}],
90108
text_base: [type: {:custom, Style.TextBase, :validate, []}],
91-
# text_height: [type: {:custom, Style.TextHeight, :validate, []}],
92-
scissor: [type: {:custom, Style.Scissor, :validate, []}],
93109
theme: [type: {:custom, Style.Theme, :validate, []}]
94110
]
95111

@@ -101,6 +117,9 @@ defmodule Scenic.Primitive.Style do
101117
@doc false
102118
def opts_schema(), do: @opts_schema
103119

120+
@doc "List of the valid style types"
121+
def valid_styles(), do: @valid_styles
122+
104123
# --------------------------------------------------------
105124
@default_styles %{
106125
font: :roboto,

0 commit comments

Comments
 (0)