bootstrap-types (empty) → 0.3
raw patch · 4 files changed
+177/−0 lines, 4 filesdep +basedep +textsetup-changed
Dependencies added: base, text
Files
- LICENSE +20/−0
- Setup.hs +2/−0
- bootstrap-types.cabal +19/−0
- src/Bootstrap/V3.hs +136/−0
+ LICENSE view
@@ -0,0 +1,20 @@+Copyright (c) 2015 Andrew Martin++Permission is hereby granted, free of charge, to any person obtaining+a copy of this software and associated documentation files (the+"Software"), to deal in the Software without restriction, including+without limitation the rights to use, copy, modify, merge, publish,+distribute, sublicense, and/or sell copies of the Software, and to+permit persons to whom the Software is furnished to do so, subject to+the following conditions:++The above copyright notice and this permission notice shall be included+in all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ bootstrap-types.cabal view
@@ -0,0 +1,19 @@+name: bootstrap-types+version: 0.3+synopsis: Bootstrap CSS Framework type-safe interface+license: MIT+license-file: LICENSE+author: Andrew Martin+maintainer: andrew.thaddeus@gmail.com+category: Web+build-type: Simple+cabal-version: >=1.10++library+ exposed-modules:+ Bootstrap.V3+ build-depends:+ base >=4.7 && <5.0+ , text+ hs-source-dirs: src+ default-language: Haskell2010
+ src/Bootstrap/V3.hs view
@@ -0,0 +1,136 @@+{-# LANGUAGE BangPatterns #-}+{-# LANGUAGE OverloadedStrings #-}++{-# OPTIONS_GHC -Wall #-}++module Bootstrap.V3+ ( Context(..)+ , Size(..)+ , Column(..)+ , Flow(..)+ , Panel(..)+ , NavbarTheme(..)+ , NavbarPosition(..)+ , NavbarItem(..)+ , NavbarDropdownItem(..)+ , contextClass+ , sizeClass+ , columnClass+ , buttonClass+ , navbarThemeClass+ , navbarPositionClass+ , emptyColumn+ , singletonColumn+ ) where++import Data.Text (Text)+import Data.Monoid+import qualified Data.Text as Text++data NavbarTheme+ = NavbarThemeDefault+ | NavbarThemeInverse+ | NavbarThemeOther Text++data NavbarPosition+ = NavbarPositionStandard+ | NavbarPositionStatic+ | NavbarPositionFixed++data NavbarItem r c+ = NavbarItemLink r c+ | NavbarItemDropdown c [NavbarDropdownItem r c]++data NavbarDropdownItem r c+ = NavbarDropdownItemLink r c+ | NavbarDropdownItemHeader c+ | NavbarDropdownItemSeparator++data Context+ = Success+ | Info+ | Warning+ | Danger+ | Default+ | Primary+ | Link+ | Error++data Size = ExtraSmall | Small | Medium | Large+ deriving (Eq,Ord)++data Column = Column+ { columnsExtraSmall :: !Int+ , columnsSmall :: !Int+ , columnsMedium :: !Int+ , columnsLarge :: !Int+ }++data Flow = Block | Inline++data Panel c = Panel+ { panelTitle :: !c+ , panelBody :: !c+ , panelContext :: !Context+ }++contextClass :: Context -> Text+contextClass x = case x of+ Success -> "success"+ Info -> "info"+ Warning -> "warning"+ Default -> "default"+ Primary -> "primary"+ Link -> "link"+ Error -> "error"+ Danger -> "danger"++sizeClass :: Size -> Text+sizeClass x = case x of+ ExtraSmall -> "xs"+ Small -> "sm"+ Medium -> "md"+ Large -> "lg"++columnClass :: Column -> Text+columnClass (Column xs sm md lg) = Text.concat+ [ "col-xs-",Text.pack (show xs)+ , " col-sm-",Text.pack (show sm)+ , " col-md-",Text.pack (show md)+ , " col-lg-",Text.pack (show lg)+ ]++emptyColumn :: Column+emptyColumn = Column 12 12 12 12++singletonColumn :: Size -> Int -> Column+singletonColumn sz i = Column+ (if sz >= ExtraSmall then i else 12)+ (if sz >= Small then i else 12)+ (if sz >= Medium then i else 12)+ (if sz >= Large then i else 12)++buttonClass :: Context -> Size -> Text+buttonClass ctx size = Text.concat+ [ "btn btn-"+ , contextClass ctx+ , " btn-"+ , sizeClass size+ ]++navbarThemeClass :: NavbarTheme -> Text+navbarThemeClass x = case x of+ NavbarThemeDefault -> "navbar-default"+ NavbarThemeInverse -> "navbar-inverse"+ NavbarThemeOther t -> "navbar-" <> t++navbarPositionClass :: NavbarPosition -> Text+navbarPositionClass x = case x of+ NavbarPositionStandard -> ""+ NavbarPositionStatic -> "navbar-static-top"+ NavbarPositionFixed -> "navbar-fixed-top"++-- setColumns :: Size -> Int -> Column -> Column+-- setColumns sz i (Column xs sm md lg) = Column++