<commit_before>(ns ^:figwheel-always prais2.faqs
    (:require [rum.core :as rum]
              [clojure.string :as str]
              [prais2.core :as core]
              [prais2.utils :refer [key-with]]
              [prais2.chrome :as chrome]
              [prais2.content :as content :refer [faq-sections]]))

(defn ix-col [index]
  (["rgba(127, 205, 187, 1)"
    "rgba(205, 127, 187, 1)"
    "rgba(127, 187, 205, 1)"
    ] (mod index 3)))

(rum/defc render-bubble-title [section-ix [index faq]]
  [:div
   (let [pull (if (even? index) "on-left" "on-right")
         ixc (ix-col index)
         faq-ref [section-ix index]]
     [:div
      [:.bubble {:class pull :style {:background-color ixc}
                 :on-click #(core/click->event-bus % :show-faq faq-ref)
                 :on-touch-start #(core/click->event-bus % :show-faq faq-ref)
                 }
       (:title faq)]
      ]
     )])

(rum/defc render-section [[section-ix faq-section]]
  [:.bubble-group
   [:h2 (:section faq-section)]
   (map-indexed key-with
                (map #(render-bubble-title section-ix %1)
                     (vec (zipmap (range) (:faqs faq-section)))))]
  )

(rum/defc render-short-answer [answer]
  [:div {:style {:margin-top "30px"}}
   [:div {:style {:margin-top "0px"
                  :width "80px"
                  :font-size "21px"
                  :font-weight 200
                  :float "left"
                  :clear "left"
                  }} [:i.fa.fa-comment {:style {:color "#FFA500"
                                                :font-size "50px"}}]]
   [:div {:style {:font-size "21px"
                  :font-weight 200
                  :margin-bottom "40px"
                  }}
    answer]])

(rum/defc render-glossary-term [term]
  (let [entry (term content/glossary)]
    (prn "rendering glossary term " term)
    [:dl
     [:dt [:i (:title entry)]]
     [:dd (:body entry)]]))

(rum/defc render-glossary [glossary]
  [:div
   [:hr]
   (map-indexed key-with
                (map #(render-glossary-term %) glossary))])

(rum/defc render-faq-menu []
  )


(rum/defc render-faqs [faq-ref]

  (prn "rendering " faq-ref)
  [:.container-fluid
   [:.row
    (if (= :top faq-ref)
      [:div
       [:h1.col-md-12 content/title]
       ;; new block menu

       ;; column 1
       [:div.col-sm-4
        (let [section (content/faq-sections 0)]
          [:div.faq-block.faq-nav-1
           [:h4 (:section section)]
           [:ul.list-unstyled
            (for [[ix faq] (map-indexed vector (:faqs section))]
              [:li [:a {:href (str "#/faq/0/" ix)} (:title faq)]])]])

        (let [section (content/faq-sections 2)]
          [:div.faq-block.faq-nav-2
           [:h4 (:section section)]
           [:ul.list-unstyled
            (for [faq (:faqs section)]
              [:li (:title faq)])]])]


       ;; column 2
       [:div.col-sm-4
        (let [section (content/faq-sections 1)]
          [:div.faq-block.faq-nav-3
           [:h4 (:section section)]
           [:ul.list-unstyled
            (for [faq (:faqs section)]
              [:li (:title faq)])]])
        ]

       ;; column 3
       [:div.col-sm-4
        (let [section (content/faq-sections 3)]
          [:div.faq-block.faq-nav-4
           [:h4 (:section section)]
           [:ul.list-unstyled
            (for [faq (:faqs section)]
              [:li (:title faq)])]])
        (let [section (content/faq-sections 4)]
          [:div.faq-block.faq-nav-4
           [:h4 (:section section)]
           [:ul.list-unstyled
            (for [faq (:faqs section)]
              [:li (:title faq)])]])
        (let [section (content/faq-sections 5)]
          [:div.faq-block.faq-nav-4
           [:h4 (:section section)]
           [:ul.list-unstyled
            (for [faq (:faqs section)]
              [:li (:title faq)])]])
        (let [section (content/faq-sections 6)]
          [:div.faq-block.faq-nav-4
           [:h4 (:section section)]
           [:ul.list-unstyled
            (for [faq (:faqs section)]
              [:li (:title faq)])]])

]




       ;; old bubble menu
       #_(map-indexed key-with
                    (map render-section
                         (vec (zipmap (range) faq-sections))))

       ]
      [:#faq.col-md-10.col-md-offset-1
       (let [[section-ix ix] faq-ref
             section (faq-sections section-ix)
             faq ((:faqs section) ix)
             short-answer (:short-answer faq)
             glossary (:glossary faq)]
         [:div
          [:h2 {:key 1}
           [:div {:style {:margin-top "-32px"
                          :width "80px"
                          :float "left"}} [:i.fa.fa-question {:style {:font-size "100px"
                                                                      :color "#FFA500"}}]]
           [:div {:style {:margin-top "40px"}}
            (:title faq)]]
          (when short-answer
            (do
              (prn "rendering short answer for section " section-ix "." ix)
              (render-short-answer short-answer)))
          [:div {:key 2
                 :style {:clear "both"}} (:body faq)]
          (when (> (count glossary) 0)
            (do
              (prn "rendering glossary " glossary)
              (render-glossary glossary)))
          [:button.btn.btn-primary
           {:key 3
            :style {:margin-bottom "100px"}
            :on-click #(core/click->event-bus % :faqs :top)
            :on-touch-start #(core/click->event-bus % :faqs :top)
            }
           "Back"
           ]])])]])<commit_msg>interim version pre Sat/Parents<commit_after>(ns ^:figwheel-always prais2.faqs
    (:require [rum.core :as rum]
              [clojure.string :as str]
              [prais2.core :as core]
              [prais2.utils :refer [key-with]]
              [prais2.chrome :as chrome]
              [prais2.content :as content :refer [faq-sections]]))

(defn ix-col [index]
  (["rgba(127, 205, 187, 1)"
    "rgba(205, 127, 187, 1)"
    "rgba(127, 187, 205, 1)"
    ] (mod index 3)))

(rum/defc render-bubble-title [section-ix [index faq]]
  [:div
   (let [pull (if (even? index) "on-left" "on-right")
         ixc (ix-col index)
         faq-ref [section-ix index]]
     [:div
      [:.bubble {:class pull :style {:background-color ixc}
                 :on-click #(core/click->event-bus % :show-faq faq-ref)
                 :on-touch-start #(core/click->event-bus % :show-faq faq-ref)
                 }
       (:title faq)]
      ]
     )])

(rum/defc render-section [[section-ix faq-section]]
  [:.bubble-group
   [:h2 (:section faq-section)]
   (map-indexed key-with
                (map #(render-bubble-title section-ix %1)
                     (vec (zipmap (range) (:faqs faq-section)))))]
  )

(rum/defc render-short-answer [answer]
  [:div {:style {:margin-top "30px"}}
   [:div {:style {:margin-top "0px"
                  :width "80px"
                  :font-size "21px"
                  :font-weight 200
                  :float "left"
                  :clear "left"
                  }} [:i.fa.fa-comment {:style {:color "#FFA500"
                                                :font-size "50px"}}]]
   [:div {:style {:font-size "21px"
                  :font-weight 200
                  :margin-bottom "40px"
                  }}
    answer]])

(rum/defc render-glossary-term [term]
  (let [entry (term content/glossary)]
    (prn "rendering glossary term " term)
    [:dl
     [:dt [:i (:title entry)]]
     [:dd (:body entry)]]))

(rum/defc render-glossary [glossary]
  [:div
   [:hr]
   (map-indexed key-with
                (map #(render-glossary-term %) glossary))])

(rum/defc render-faq-block [sec-ix block-class]
  (let [section (content/faq-sections sec-ix)]
    [:div.faq-block {:class block-class}
     [:h4 (:section section)]
     [:ul.list-unstyled
      (for [[ix faq] (map-indexed vector (:faqs section))]
        [:li [:a {:href (str "#/faq/" sec-ix "/" ix)} (:title faq)]])]]))


(rum/defc render-faq-top [faq-ref]
  [:div
   [:h1.col-md-12 content/title]
   ;; new block menu

   ;; column 1
   [:div.col-sm-4
    (render-faq-block 0 "faq-nav-1")
    (render-faq-block 2 "faq-nav-2")]

   ;; column 2
   [:div.col-sm-4
    (render-faq-block 1 "faq-nav-3")]

   ;; column 3
   [:div.col-sm-4
    (render-faq-block 3 "faq-nav-4")
    (render-faq-block 4 "faq-nav-4")
    (render-faq-block 5 "faq-nav-4")
    (render-faq-block 6 "faq-nav-4")]

   ;; old bubble menu
   #_(map-indexed key-with
                  (map render-section
                       (vec (zipmap (range) faq-sections))))])


(rum/defc render-faq-section [faq-ref]
  [:#faq.col-md-10.col-md-offset-1
     (let [[section-ix ix] faq-ref
           section (faq-sections section-ix)
           faq ((:faqs section) ix)
           short-answer (:short-answer faq)
           glossary (:glossary faq)]
       [:div
        [:h2 {:key 1}
         [:div {:style {:margin-top "-32px"
                        :width "80px"
                        :float "left"}} [:i.fa.fa-question {:style {:font-size "100px"
                                                                    :color "#FFA500"}}]]
         [:div {:style {:margin-top "40px"}}
          (:title faq)]]
        (when short-answer
          (do
            (prn "rendering short answer for section " section-ix "." ix)
            (render-short-answer short-answer)))
        [:div {:key 2
               :style {:clear "both"}} (:body faq)]
        (when (> (count glossary) 0)
          (do
            (prn "rendering glossary " glossary)
            (render-glossary glossary)))
        [:button.btn.btn-primary
         {:key 3
          :style {:margin-bottom "100px"}
          :on-click #(core/click->event-bus % :faqs :top)
          :on-touch-start #(core/click->event-bus % :faqs :top)
          }
         "Back"
         ]])])


(rum/defc render-faqs [faq-ref]

  [:.container-fluid
   [:.row

    (if (= :top faq-ref)
      (render-faq-top faq-ref)
      (render-faq-section faq-ref)
      )
    ]])
{'fraction_non_alphanumeric': 0.16828123439528614, 'fraction_numerical': 0.022071307300509338, 'mean_word_length': 1.5709884467265725, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 9, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4585651', 'n_tokens_mistral': 3744, 'n_tokens_neox': 3355, 'n_words': 762}