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

[WIP] Refactor text style props #541

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
36 changes: 1 addition & 35 deletions src/UI/Style.re
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ module PointerEvents = {
type t = {
backgroundColor: Color.t,
boxShadow: BoxShadow.t,
color: Color.t,
width: int,
height: int,
position: LayoutTypes.positionType,
Expand All @@ -78,11 +77,7 @@ type t = {
bottom: int,
left: int,
right: int,
fontFamily,
fontSize: int,
lineHeight: float,
pointerEvents: PointerEvents.t,
textWrap: TextWrapping.wrapType,
marginTop: int,
marginLeft: int,
marginRight: int,
Expand All @@ -101,7 +96,6 @@ type t = {
padding: int,
paddingVertical: int,
paddingHorizontal: int,
textOverflow: TextOverflow.t,
overflow: LayoutTypes.overflow,
borderTop: Border.t,
borderLeft: Border.t,
Expand All @@ -118,7 +112,6 @@ type t = {

let make =
(
~textOverflow=TextOverflow.Overflow,
~backgroundColor: Color.t=Colors.transparentBlack,
~boxShadow=BoxShadow.default,
~color: Color.t=Colors.white,
Expand All @@ -137,9 +130,6 @@ let make =
~bottom=Encoding.cssUndefined,
~left=Encoding.cssUndefined,
~right=Encoding.cssUndefined,
~fontFamily="",
~fontSize=Encoding.cssUndefined,
~lineHeight=1.2,
~textWrap=TextWrapping.WhitespaceWrap,
~marginTop=Encoding.cssUndefined,
~marginLeft=Encoding.cssUndefined,
Expand Down Expand Up @@ -175,7 +165,6 @@ let make =
_unit: unit,
) => {
let ret: t = {
textOverflow,
backgroundColor,
boxShadow,
color,
Expand All @@ -194,10 +183,6 @@ let make =
bottom,
left,
right,
fontFamily,
fontSize,
lineHeight,
textWrap,
transform,
marginTop,
marginLeft,
Expand Down Expand Up @@ -352,24 +337,15 @@ type coreStyleProps = [
| `PointerEvents(PointerEvents.t)
];

type fontProps = [ | `FontFamily(string) | `FontSize(int)];

type textProps = [
| `LineHeight(float)
| `TextWrap(TextWrapping.wrapType)
| `TextOverflow(TextOverflow.t)
];

/*
Text and View props take different style properties as such
these nodes are typed to only allow styles to be specified
which are relevant to each
*/
type textStyleProps = [ textProps | fontProps | coreStyleProps];
type viewStyleProps = [ coreStyleProps];
type imageStyleProps = [ coreStyleProps];

type allProps = [ coreStyleProps | fontProps | textProps];
type allProps = [ coreStyleProps ];

let emptyTextStyle: list(textStyleProps) = [];
let emptyViewStyle: list(viewStyleProps) = [];
Expand Down Expand Up @@ -439,11 +415,6 @@ let bottom = f => `Bottom(f);
let left = f => `Left(f);
let top = f => `Top(f);

let fontSize = f => `FontSize(f);
let fontFamily = f => `FontFamily(f);
let lineHeight = h => `LineHeight(h);
let textWrap = w => `TextWrap(w);

let height = h => `Height(h);
let width = w => `Width(w);

Expand Down Expand Up @@ -597,11 +568,6 @@ let applyStyle = (style, styleRule) =>
| `BorderRadius(borderRadius) => {...style, borderRadius}
| `Opacity(opacity) => {...style, opacity}
| `Transform(transform) => {...style, transform}
| `FontFamily(fontFamily) => {...style, fontFamily}
| `FontSize(fontSize) => {...style, fontSize}
| `LineHeight(lineHeight) => {...style, lineHeight}
| `TextOverflow(textOverflow) => {...style, textOverflow}
| `TextWrap(textWrap) => {...style, textWrap}
| `Cursor(cursor) => {...style, cursor}
| `Color(color) => {...style, color}
| `BackgroundColor(backgroundColor) => {...style, backgroundColor}
Expand Down