From 55e12a17000d02ff3a7d1097390c520dc2e47d1f Mon Sep 17 00:00:00 2001 From: Vasiliy Yorkin Date: Thu, 5 Jul 2018 20:26:55 +0300 Subject: [PATCH 1/3] Add text direction --- src/CSS.purs | 1 + src/CSS/Text.purs | 2 +- src/CSS/Text/Direction.purs | 24 ++++++++++++++++++++++++ test/Main.purs | 8 +++++++- 4 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 src/CSS/Text/Direction.purs diff --git a/src/CSS.purs b/src/CSS.purs index eb4b9db..d69271f 100644 --- a/src/CSS.purs +++ b/src/CSS.purs @@ -21,6 +21,7 @@ import CSS.Size (Abs, Angle(..), Deg, Rad, Rel, Size(..), deg, em, ex, nil, pct, import CSS.String (class IsString, fromString) as X import CSS.Stylesheet (App(..), CSS, Feature(..), Keyframes(..), MediaQuery(..), MediaType(..), NotOrOnly(..), Rule(..), StyleM(..), fontFace, importUrl, key, keyframes, keyframesFromTo, prefixed, query, rule, runS, select, (?)) as X import CSS.Text (TextDecoration(..), blink, letterSpacing, lineThrough, noneTextDecoration, overline, textDecoration, underline) as X +import CSS.Text.Direction (TextDirection(..), direction) as X import CSS.Text.Whitespace (TextWhitespace, textWhitespace, whitespaceNoWrap, whitespaceNormal, whitespacePre, whitespacePreLine, whitespacePreWrap) as X import CSS.Text.Transform (TextTransform, textTransform) as X import CSS.Text.Overflow (TextOverflow, textOverflow) as X diff --git a/src/CSS/Text.purs b/src/CSS/Text.purs index 4dabe5c..e5eef25 100644 --- a/src/CSS/Text.purs +++ b/src/CSS/Text.purs @@ -12,7 +12,7 @@ letterSpacing = key $ fromString "letter-spacing" newtype TextDecoration = TextDecoration Value derive instance eqTextDecoration :: Eq TextDecoration -derive instance ordTextDecoration:: Ord TextDecoration +derive instance ordTextDecoration :: Ord TextDecoration instance valTextDecoration :: Val TextDecoration where value (TextDecoration v) = v diff --git a/src/CSS/Text/Direction.purs b/src/CSS/Text/Direction.purs new file mode 100644 index 0000000..4ebcc7e --- /dev/null +++ b/src/CSS/Text/Direction.purs @@ -0,0 +1,24 @@ +module CSS.Text.Direction where + +import Prelude +import CSS.Property (class Val) +import CSS.String (fromString) +import CSS.Stylesheet (CSS, key) + +data TextDirection = Ltr | Rtl + +derive instance eqTextDirection :: Eq TextDirection +derive instance ordTextDirection :: Ord TextDirection + +instance valTextDirection :: Val TextDirection where + value Ltr = fromString "ltr" + value Rtl = fromString "rtl" + +direction :: TextDirection -> CSS +direction = key $ fromString "direction" + +ltr :: TextDirection +ltr = Ltr + +rtl :: TextDirection +rtl = Rtl diff --git a/test/Main.purs b/test/Main.purs index 4f0300a..ecb48ad 100644 --- a/test/Main.purs +++ b/test/Main.purs @@ -4,9 +4,10 @@ import Prelude import Effect (Effect) import Effect.Exception (error, throwException) -import CSS (Rendered, Path(..), Predicate(..), Refinement(..), Selector(..), FontFaceSrc(..), FontFaceFormat(..), renderedSheet, renderedInline, fromString, selector, block, display, render, borderBox, boxSizing, contentBox, blue, color, body, a, p, px, dashed, border, inlineBlock, red, (?), (&), (|>), (|*), (|+), byId, byClass, (@=), (^=), ($=), (*=), (~=), (|=), hover, fontFaceSrc, fontStyle, deg, zIndex, textOverflow, opacity) +import CSS (Rendered, Path(..), Predicate(..), Refinement(..), Selector(..), FontFaceSrc(..), FontFaceFormat(..), renderedSheet, renderedInline, fromString, selector, block, display, render, borderBox, boxSizing, contentBox, blue, color, body, a, p, px, dashed, border, inlineBlock, red, (?), (&), (|>), (|*), (|+), byId, byClass, (@=), (^=), ($=), (*=), (~=), (|=), hover, fontFaceSrc, fontStyle, deg, zIndex, textOverflow, opacity, direction) import CSS.FontStyle as FontStyle import CSS.Text.Overflow as TextOverflow +import CSS.Text.Direction as TextDirection import Data.Maybe (Maybe(..)) import Data.NonEmpty (singleton) @@ -115,6 +116,10 @@ exampleTextOverflow2 :: Rendered exampleTextOverflow2 = render do textOverflow $ TextOverflow.custom "foobar" +exampleDirection :: Rendered +exampleDirection = render do + direction TextDirection.rtl + nestedNodes :: Rendered nestedNodes = render do fromString "#parent" ? do @@ -171,3 +176,4 @@ main = do renderedSheet attrSpace `assertEqual` Just "p[foo~='bar'] { display: block }\n" renderedSheet attrHyph `assertEqual` Just "p[foo|='bar'] { display: block }\n" + renderedInline exampleDirection `assertEqual` Just "direction: rtl" From 63b31c47873e55193e6ee24350f149c7a5e73102 Mon Sep 17 00:00:00 2001 From: Jordan Martinez Date: Thu, 23 Sep 2021 07:35:09 -0700 Subject: [PATCH 2/3] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 669a3e3..9eb2212 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ Breaking changes: New features: - Add smart constructors for generic font families (#68, #136 by @Unisay and @JordanMartinez) +- Add support for `text-direction` (#83 by @vyorkin) Bugfixes: From 5f87cae1488e5139951230192df83d5156a6d0fe Mon Sep 17 00:00:00 2001 From: Jordan Martinez Date: Thu, 23 Sep 2021 07:36:39 -0700 Subject: [PATCH 3/3] Update PR number --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9eb2212..bf62124 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ Breaking changes: New features: - Add smart constructors for generic font families (#68, #136 by @Unisay and @JordanMartinez) -- Add support for `text-direction` (#83 by @vyorkin) +- Add support for `text-direction` (#83, #137 by @vyorkin and @JordanMartinez) Bugfixes: