git.iko.soy/rowtype-yoga/purescript-fahrtwind
on main help sign in
Add more gradient options
commit0dbacaa6f2527c863d89c51900cf34b5b69e4b62 authorMark Eibes <mark.eibes@gmail.com> dateSat 3 Dec 2022, 19:02 (4 years ago) parentba99ec7
3 files changed+34−8
src/Fahrtwind/Style.purs+2−2 src/Fahrtwind/Style/Color/Background.purs+11−4 src/Fahrtwind/Style/Text.purs+21−2
src/Fahrtwind/Style.purs+2−2
@@ -40,7 +40,7 @@ import Fahrtwind.Style.Border (border, borderBottom, borderCol, borderCol', bord
4040import Fahrtwind.Style.BoxModel (m', mB, mB', mL, mL', mR, mR', mT, mT', mX, mX', mXAuto, mXY, mY, mY', p', pB, pB', pL, pL', pR, pR', pT, pT', pX, pX', pXY, pY, pY')
4141import Fahrtwind.Style.BoxShadow (mkShadow, shadow, shadow', shadowDefault, shadowDefaultCol, shadowLg, shadowLgCol, shadowMd, shadowMdCol, shadowSm, shadowSmCol, shadowXl, shadowXlCol, shadowXxl, shadowXxlCol, shadows)
4242import Fahrtwind.Style.Breakpoint (screen2xl, screenLg, screenMd, screenSm, screenXl)
43−import Fahrtwind.Style.Color.Background (background, background', backgroundImage, backgroundImage', backgroundNoRepeat, backgroundPosition, backgroundRepeat, backgroundRepeatX, backgroundRepeatY, backgroundSize, backgroundSize', blurredBackground, blurredBackground', linearGradient, linearGradientStops, linearGradientStopsString, linearGradientString, svgBackgroundImage)
43+import Fahrtwind.Style.Color.Background (background, background', backgroundImage, backgroundImage', backgroundNoRepeat, backgroundPosition, backgroundRepeat, backgroundRepeatX, backgroundRepeatY, backgroundSize, backgroundSize', blurredBackground, blurredBackground', linearGradient, linearGradient', linearGradientStops, linearGradientStopsString, linearGradientString, svgBackgroundImage)
4444import Fahrtwind.Style.Color.Tailwind (TailwindColor, amber, black, blue, blueGray, coolGray, cyan, emerald, fuchsia, gray, green, indigo, lightBlue, lime, orange, pink, purple, red, rose, teal, trueGray, violet, warmGray, white, yellow)
4545import Fahrtwind.Style.Color.Text (textCenter, textCol, textCol', textJustify, textLeft, textRight)
4646import Fahrtwind.Style.Color.Util (hue, lightness, saturation, withAlpha, withHue, withLightness, withSaturation)
@@ -61,7 +61,7 @@ import Fahrtwind.Style.Position (positionAbsolute, positionFixed, positionRelati
6161import Fahrtwind.Style.PseudoClasses (active, checked, default, disabled, empty, enabled, evenChild, first, firstChild, firstOfType, focus, focusWithin, fullscreen, hover, inRange, indeterminate, invalid, lastChild, lastOfType, link, nthChild, nthOfType, oddChild, onlyChild, onlyOfType, optional, outOfRange, pseudoLeft, pseudoRight, readOnly, readWrite, required, root, scope, target, valid, visited)
6262import Fahrtwind.Style.PseudoElements (afterElement, beforeElement, content, firstLetter, firstLine, selection)
6363import Fahrtwind.Style.Size (full, height, height', heightFull, heightScreen, maxHeight, maxHeight', maxWidth, maxWidth', minHeight, minHeight', minWidth, minWidth', screenHeight, screenWidth, width, width', widthAndHeight, widthAndHeight', widthFull, widthScreen)
64−import Fahrtwind.Style.Text (fontBlack, fontBold, fontExtrabold, fontExtralight, fontFamilyOrMono, fontFamilyOrSans, fontFamilyOrSerif, fontLight, fontMedium, fontNormal, fontSemiMedium, fontSemibold, fontSize, fontSize', fontThin, lineHeight, lineHeight', text2xl, text3xl, text4xl, text5xl, text6xl, text7xl, text8xl, text9xl, textBase, textDefault, textLg, textSized, textSm, textTransformUppercase, textXl, textXs, tracking, trackingNormal, trackingTight, trackingTighter, trackingWide, trackingWider, trackingWidest, underline)
64+import Fahrtwind.Style.Text (fontBlack, fontBold, fontExtrabold, fontExtralight, fontFamilyOrMono, fontFamilyOrSans, fontFamilyOrSerif, fontLight, fontMedium, fontNormal, fontSemiMedium, fontSemibold, fontSize, fontSize', fontThin, italic, lineHeight, lineHeight', noTextDecoration, text2xl, text3xl, text4xl, text5xl, text6xl, text7xl, text8xl, text9xl, textBase, textDefault, textLg, textLinearGradient, textSized, textSm, textTransformUppercase, textXl, textXs, tracking, trackingNormal, trackingTight, trackingTighter, trackingWide, trackingWider, trackingWidest, underline)
6565import Fahrtwind.Style.Transform (mkRotate, mkTranslate, rotate, transform, transform', transformMany, translate)
6666import Fahrtwind.Style.Transition (transition, transition', transitionRec)
6767import Fahrtwind.Style.UserSelect (userSelectNone, userSelectText)
src/Fahrtwind/Style/Color/Background.purs+11−4
@@ -38,8 +38,8 @@ svgMaskImage = maskImage <<< embeddedJSX
3838embeddedJSX ∷ JSX → String
3939embeddedJSX jsx =
4040 "url('data:image/svg+xml;utf8,"
41− <> renderToStaticMarkup jsx
42− <> "')"
41+ <> renderToStaticMarkup jsx
42+ <> "')"
4343
4444backgroundPosition ∷ String → Style
4545backgroundPosition bp = css { backgroundPosition: str bp }
@@ -62,6 +62,13 @@ backgroundSize' = css <<< { backgroundSize: _ }
6262backgroundSize ∷ String → Style
6363backgroundSize = backgroundSize' <<< str
6464
65+linearGradient' :: Int -> Array String -> Style
66+linearGradient' deg colours = css { background: str bg }
67+ where
68+ bg = "linear-gradient(" <> show deg <> "deg, "
69+ <> intercalate "," (colours)
70+ <> ")"
71+
6572linearGradient ∷ Int → Array Color → Style
6673linearGradient deg colors = css { background: str bg }
6774 where
@@ -103,8 +110,8 @@ blurredBackground col blurRadius =
103110 , blurRadius
104111 }
105112
106−blurredBackground' ∷
107− { blurredCol ∷ String, fallbackCol ∷ String, blurRadius ∷ Int } → Style
113+blurredBackground'
114+ ∷ { blurredCol ∷ String, fallbackCol ∷ String, blurRadius ∷ Int } → Style
108115blurredBackground' { blurredCol, fallbackCol, blurRadius } =
109116 css
110117 { background: str $ fallbackCol
src/Fahrtwind/Style/Text.purs+21−2
@@ -2,7 +2,8 @@ module Fahrtwind.Style.Text where
22
33import Prelude
44
5−import React.Basic.Emotion (Style, StyleProperty, css, em, int, px, rem, str)
5+import Data.Array (intercalate)
6+import React.Basic.Emotion (Style, StyleProperty, css, em, int, none, px, rem, str)
67
78textSized ∷ Number → Number → Style
89textSized fs lh = css { fontSize: fs # rem, lineHeight: lh # rem }
@@ -124,5 +125,23 @@ fontFamilyOrMono ff = css { fontFamily: str $ ff <> ", monospace" }
124125underline ∷ Style
125126underline = css { textDecoration: str "underline" }
126127
128+noTextDecoration ∷ Style
129+noTextDecoration = css { textDecoration: none }
130+
131+italic ∷ Style
132+italic = css { fontStyle: str "italic" }
133+
134+textLinearGradient :: Int -> Array String -> Style
135+textLinearGradient deg colours =
136+ css
137+ { backgroundClip: str "text"
138+ , textFillColor: str "transparent"
139+ , background: str bg
140+ }
141+ where
142+ bg = "linear-gradient(" <> show deg <> "deg, "
143+ <> intercalate "," (colours)
144+ <> ")"
145+
127146textTransformUppercase ∷ Style
128−textTransformUppercase = css { textTransform: str "uppercase" }
147+textTransformUppercase = css { textTransform: str "uppercase" }