From a3114ed235b4630ac9c279b6c0d6e28b11fbfdd3 Mon Sep 17 00:00:00 2001 From: Philippe Pittoli Date: Tue, 6 May 2025 01:01:49 +0200 Subject: [PATCH] No more Bulma module. --- src/App/Templates/Table.purs | 3 +- src/Bulma.purs | 57 ------------------------------------ src/Web.purs | 23 +++++++++------ src/Web/Basics.purs | 3 ++ src/Web/Data.purs | 7 +++++ src/Web/Header.purs | 14 +++++++-- src/Web/Level.purs | 20 +++++++++++++ src/Web/Section.purs | 12 ++++++++ src/Web/Tag.purs | 3 ++ src/Web/Tile.purs | 21 +++++++++++++ 10 files changed, 92 insertions(+), 71 deletions(-) delete mode 100644 src/Bulma.purs create mode 100644 src/Web/Data.purs create mode 100644 src/Web/Level.purs create mode 100644 src/Web/Section.purs create mode 100644 src/Web/Tile.purs diff --git a/src/App/Templates/Table.purs b/src/App/Templates/Table.purs index 166b002..727f10f 100644 --- a/src/App/Templates/Table.purs +++ b/src/App/Templates/Table.purs @@ -22,7 +22,6 @@ import Data.Tuple (Tuple(..)) import Web as Web import Web.Button as Button -import Bulma as Bulma import Halogen.HTML as HH import Halogen.HTML.Properties as HP import Data.String.CodePoints as CP @@ -96,7 +95,7 @@ shared_domains domains_i_share action_enter_domain action_unshare_domain action_ -- | Render all Resource Records. resource_records :: forall w i. Array ResourceRecord -> (Int -> i) -> (Int -> i) -> (Int -> i) -> HH.HTML w i -resource_records [] _ _ _ = Web.box [Bulma.zone_rr_title "Resource records", Bulma.subtitle "No records for now"] +resource_records [] _ _ _ = Web.box [Web.title "Resource records", Web.subtitle "No records for now"] resource_records records action_create_or_update_rr action_delete_rr action_new_token = HH.div_ $ (rr_box [bg_color_ro] tag_soa soa_table_header table_content all_soa_rr) diff --git a/src/Bulma.purs b/src/Bulma.purs deleted file mode 100644 index e604e3b..0000000 --- a/src/Bulma.purs +++ /dev/null @@ -1,57 +0,0 @@ --- | The `Bulma` module is a wrapper around the BULMA css framework. -module Bulma where -import Prelude (map, ($), (<>)) - -import Halogen.HTML as HH -import Halogen.HTML.Properties as HP -import Halogen.HTML.Events as HE - -import CSSClasses as C - -import Halogen.HTML.Core (AttrName(..)) --- import Web.Event.Event (type_, Event, EventType(..)) --- import Web.UIEvent.MouseEvent (MouseEvent) -- package web-uievents - -outside_link :: forall w i. Array HH.ClassName -> String -> String -> HH.HTML w i -outside_link classes url title = HH.a [ HP.classes classes, HP.target "_blank", HP.href url ] [ HH.text title ] - -zone_rr_title :: forall (w :: Type) (a :: Type). String -> HH.HTML w a -zone_rr_title title - = HH.h3 [ HP.classes [C.title, C.has_text_light, C.has_background_dark] ] - [ HH.text title ] - -subtitle :: forall (w :: Type) (a :: Type). String -> HH.HTML w a -subtitle title = HH.h2 [ HP.classes [C.subtitle, C.is4] ] [ HH.text title ] - --- | Create a `level`, different components that should appear on the same horizontal line. --- | First argument, elements that should appear on the left, second on the right. -level :: forall w i. Array (HH.HTML w i) -> Array (HH.HTML w i) -> HH.HTML w i -level left right = HH.nav [ HP.classes [C.level] ] - [ HH.div [ HP.classes [C.level_left] ] $ itemize left - , HH.div [ HP.classes [C.level_right] ] $ itemize right - ] - where itemize = map (\v -> HH.div [ HP.classes [C.level_item] ] [v]) - -section_small :: forall w i. Array (HH.HTML w i) -> HH.HTML w i -section_small = HH.section [ HP.classes [C.section, C.is_small] ] - -section_medium :: forall w i. Array (HH.HTML w i) -> HH.HTML w i -section_medium = HH.section [ HP.classes [C.section, C.medium] ] - -data_target :: forall r i. String -> HP.IProp r i -data_target = HP.attr (AttrName "data-target") - -tile :: forall w i. Array HH.ClassName -> Array (HH.HTML w i) -> HH.HTML w i -tile classes = HH.div [HP.classes ([C.tile] <> classes)] - -tile_ :: forall w i. Array (HH.HTML w i) -> HH.HTML w i -tile_ = tile [] - -tile_danger :: forall w i. Array HH.ClassName -> Array (HH.HTML w i) -> HH.HTML w i -tile_danger classes = tile $ [C.is_danger, C.notification] <> classes - -tile_warning :: forall w i. Array HH.ClassName -> Array (HH.HTML w i) -> HH.HTML w i -tile_warning classes = tile $ [C.is_warning, C.notification] <> classes - -tag_light_info :: forall w i. String -> HH.HTML w i -tag_light_info str = HH.span [HP.classes [C.tag, C.is_info, C.is_light]] [HH.text str] diff --git a/src/Web.purs b/src/Web.purs index 3c79f63..959a0e9 100644 --- a/src/Web.purs +++ b/src/Web.purs @@ -1,36 +1,41 @@ -- | `Web` module is an abstraction over most HTML-related code in order -- | to have a consistent style through all the website. module Web - ( module Bulma - , module Web.Basics + ( module Web.Basics , module Web.Box , module Web.Button , module Web.Checkbox , module Web.Column + , module Web.Data , module Web.Field , module Web.Header , module Web.Hero , module Web.Input + , module Web.Level , module Web.Modal , module Web.Notification + , module Web.Section , module Web.Tab , module Web.Table , module Web.Tag + , module Web.Tile ) where -import Web.Basics -import Web.Box +import Web.Basics (article, article_, code, container, div_content, div_large_content, error_message, explanation, hdiv, hr, p, p_, quote, simple_quote, strong, text, textarea, textarea_, outside_link) +import Web.Box (box, box_, box_with_tag) import Web.Button (alert_btn, alert_btn_abbr, btn, btn_, btn_abbr, btn_abbr_, btn_add, btn_delete, btn_delete_ro, btn_modify, btn_modify_ro, btn_readonly, btn_ro, btn_save, btn_validation, btn_validation_, cancel_button, delete_btn) import Web.Checkbox (checkbox) import Web.Column (column, column_, columns, columns_) +import Web.Data (data_target) import Web.Field (btn_labeled, div_field, div_field_, div_field_content, div_field_label, error_field_entry, field_entry, new_domain_field, option, select, selection, selection', selection_field, selection_field', selection_field'', side_text_above_input) -import Web.Header (h1, h3, h4) +import Web.Header (h1, h3, h4, title, subtitle) import Web.Hero (hero, hero_danger, hero_danger_txt, small_hero) import Web.Input (box_input, box_input_, box_password, box_password_, email_input, field_inner, input_classes, input_with_side_text, password_input, password_input_confirmation, password_input_new, render_input, token_input, username_input) +import Web.Level (level) import Web.Modal (modal, modal_, modal_background, modal_body, modal_card_large, modal_foot, modal_header) import Web.Notification (error_box, notification, notification', notification_block', notification_danger, notification_danger', notification_danger_block', notification_primary, notification_primary', notification_success, notification_warning, notification_warning') -import Web.Table (table, table_) +import Web.Section (section_medium, section_small) import Web.Tab (fancy_tabs, tab_entry, tabs) -import Web.Tag (tag, tag_ro, tags) - -import Bulma +import Web.Table (table, table_) +import Web.Tag (tag, tag_ro, tags, tag_light_info) +import Web.Tile (tile, tile_, tile_danger, tile_warning) diff --git a/src/Web/Basics.purs b/src/Web/Basics.purs index 7dee52f..d153e95 100644 --- a/src/Web/Basics.purs +++ b/src/Web/Basics.purs @@ -70,3 +70,6 @@ textarea_ classes placeholder value action textarea :: forall w i. String -> String -> (String -> i) -> HH.HTML w i textarea placeholder value action = textarea_ [] placeholder value action + +outside_link :: forall w a. Array HH.ClassName -> String -> String -> HH.HTML w a +outside_link classes url str = HH.a [ HP.classes classes, HP.target "_blank", HP.href url ] [ HH.text str ] diff --git a/src/Web/Data.purs b/src/Web/Data.purs new file mode 100644 index 0000000..7af82b7 --- /dev/null +++ b/src/Web/Data.purs @@ -0,0 +1,7 @@ +module Web.Data where + +import Halogen.HTML.Properties as HP +import Halogen.HTML.Core (AttrName(..)) + +data_target :: forall r i. String -> HP.IProp r i +data_target = HP.attr (AttrName "data-target") diff --git a/src/Web/Header.purs b/src/Web/Header.purs index 74c8fd6..bff8d2a 100644 --- a/src/Web/Header.purs +++ b/src/Web/Header.purs @@ -6,10 +6,18 @@ import Halogen.HTML.Properties as HP import CSSClasses as C h1 :: forall (w :: Type) (a :: Type). String -> HH.HTML w a -h1 title = HH.h1 [ HP.classes [C.title] ] [ HH.text title ] +h1 str = HH.h1 [ HP.classes [C.title] ] [ HH.text str ] h3 :: forall (w :: Type) (a :: Type). String -> HH.HTML w a -h3 title = HH.h3 [ HP.classes [C.title] ] [ HH.text title ] +h3 str = HH.h3 [ HP.classes [C.title] ] [ HH.text str ] h4 :: forall (w :: Type) (a :: Type). String -> HH.HTML w a -h4 title = HH.h4 [ HP.classes [C.title] ] [ HH.text title ] +h4 str = HH.h4 [ HP.classes [C.title] ] [ HH.text str ] + +title :: forall w a. String -> HH.HTML w a +title title_str + = HH.h3 [ HP.classes [C.title, C.has_text_light, C.has_background_dark] ] + [ HH.text title_str ] + +subtitle :: forall w a. String -> HH.HTML w a +subtitle str = HH.h2 [ HP.classes [C.subtitle, C.is4] ] [ HH.text str ] diff --git a/src/Web/Level.purs b/src/Web/Level.purs new file mode 100644 index 0000000..1016f94 --- /dev/null +++ b/src/Web/Level.purs @@ -0,0 +1,20 @@ +module Web.Level where + +import Prelude (map, ($)) + +import Halogen.HTML as HH +import Halogen.HTML.Properties as HP + +import CSSClasses as C + +-- import Web.Event.Event (type_, Event, EventType(..)) +-- import Web.UIEvent.MouseEvent (MouseEvent) -- package web-uievents + +-- | Create a `level`, different components that should appear on the same horizontal line. +-- | First argument, elements that should appear on the left, second on the right. +level :: forall w a. Array (HH.HTML w a) -> Array (HH.HTML w a) -> HH.HTML w a +level left right = HH.nav [ HP.classes [C.level] ] + [ HH.div [ HP.classes [C.level_left] ] $ itemize left + , HH.div [ HP.classes [C.level_right] ] $ itemize right + ] + where itemize = map (\v -> HH.div [ HP.classes [C.level_item] ] [v]) diff --git a/src/Web/Section.purs b/src/Web/Section.purs new file mode 100644 index 0000000..ecaa246 --- /dev/null +++ b/src/Web/Section.purs @@ -0,0 +1,12 @@ +module Web.Section where + +import Halogen.HTML as HH +import Halogen.HTML.Properties as HP + +import CSSClasses as C + +section_small :: forall w i. Array (HH.HTML w i) -> HH.HTML w i +section_small = HH.section [ HP.classes [C.section, C.is_small] ] + +section_medium :: forall w i. Array (HH.HTML w i) -> HH.HTML w i +section_medium = HH.section [ HP.classes [C.section, C.medium] ] diff --git a/src/Web/Tag.purs b/src/Web/Tag.purs index 3887dcc..97e3fa6 100644 --- a/src/Web/Tag.purs +++ b/src/Web/Tag.purs @@ -13,3 +13,6 @@ tag str = HH.span [HP.classes [C.tag, C.is_dark]] [HH.text str] tag_ro :: forall w i. String -> HH.HTML w i tag_ro str = HH.span [HP.classes [C.tag, C.is_warning]] [HH.text str] + +tag_light_info :: forall w i. String -> HH.HTML w i +tag_light_info str = HH.span [HP.classes [C.tag, C.is_info, C.is_light]] [HH.text str] diff --git a/src/Web/Tile.purs b/src/Web/Tile.purs new file mode 100644 index 0000000..a1fcdf3 --- /dev/null +++ b/src/Web/Tile.purs @@ -0,0 +1,21 @@ +module Web.Tile where + +import Prelude (($), (<>)) + +import Halogen.HTML as HH +import Halogen.HTML.Properties as HP + +import CSSClasses as C + +tile :: forall w i. Array HH.ClassName -> Array (HH.HTML w i) -> HH.HTML w i +tile classes = HH.div [HP.classes ([C.tile] <> classes)] + +tile_ :: forall w i. Array (HH.HTML w i) -> HH.HTML w i +tile_ = tile [] + +tile_danger :: forall w i. Array HH.ClassName -> Array (HH.HTML w i) -> HH.HTML w i +tile_danger classes = tile $ [C.is_danger, C.notification] <> classes + +tile_warning :: forall w i. Array HH.ClassName -> Array (HH.HTML w i) -> HH.HTML w i +tile_warning classes = tile $ [C.is_warning, C.notification] <> classes +