<commit_before>module Levels where

import Graphics.Element (Element, flow, down, right, spacer, color)
import Window
import Signal
import List ((::))
import List

import Layout (toColText, toDefText, green1, blue1, darkGray1
  , niceButton, defaultSpacer, quadDefSpacer, toSizedText, niceButtonSize
  , centerHorizontally, divider, doubleDefSpacer)
import Skeleton

levelButton : String -> Element
levelButton s = niceButtonSize 28 s ("?page=game&level=" ++ s)

main : Signal Element
main = Signal.map2 scene Window.width Window.height

{-| splitEvery [1,2,3,4,5,6,7,8] === [[1,2,3],[4,5,6],[7,8]] -}
splitEvery : Int -> List a -> List (List a)
splitEvery n xs =
  if List.length xs > n
    then (List.take n xs) :: (List.drop n xs |> splitEvery n)
    else [xs]

asGrid : Int -> List Element -> Element
asGrid colCnt =
  splitEvery colCnt
  >> List.map (List.intersperse quadDefSpacer >> flow right)
  >> List.intersperse quadDefSpacer
  >> flow down

subjects : List (String, List String)
subjects =
  [ ( "Warm up"
    , [
        "just_type"
      , "delete_chars"
      , "word_swap"
      , "line_swap"
      , "remove_words_1"
      ]
    )
  , ( "Strength"
    , [
        "insert"
      , "new_lines"
      , "remove_words_2"
      , "replace_words"
      , "batman"
      ]
    )
  , ( "Endurance"
    , [
        "numbers"
      , "swap_many_words"
      ]
    )
  , ( "Stretching"
    , [
        "alignment"
      , "more_lines"
      , "i_am_awesome"
      ]
    )
  ]

showSubject : Int -> String -> List String -> Element
showSubject w subject levels =
  let subjectElem = toSizedText 48 subject |> centerHorizontally w
      levelsElem =
        levels
        |> List.map levelButton
        |> asGrid 3
        |> centerHorizontally w
  in flow down [ subjectElem, doubleDefSpacer, levelsElem ]

scene : Int -> Int -> Element
scene w h =
  let paddedDivider = flow down [
                          doubleDefSpacer
                        , divider blue1 w
                        , doubleDefSpacer
                      ]
  in  subjects
        |> List.map (showSubject w |> uncurry)
        |> List.intersperse paddedDivider
        |> flow down
        |> Skeleton.showPage w h<commit_msg>font size<commit_after>module Levels where

import Graphics.Element (Element, flow, down, right, spacer, color)
import Window
import Signal
import List ((::))
import List

import Layout (toColText, toDefText, green1, blue1, darkGray1
  , niceButton, defaultSpacer, quadDefSpacer, toSizedText, niceButtonSize
  , centerHorizontally, divider, doubleDefSpacer)
import Skeleton

levelButton : String -> Element
levelButton s = niceButtonSize 26 s ("?page=game&level=" ++ s)

main : Signal Element
main = Signal.map2 scene Window.width Window.height

{-| splitEvery [1,2,3,4,5,6,7,8] === [[1,2,3],[4,5,6],[7,8]] -}
splitEvery : Int -> List a -> List (List a)
splitEvery n xs =
  if List.length xs > n
    then (List.take n xs) :: (List.drop n xs |> splitEvery n)
    else [xs]

asGrid : Int -> List Element -> Element
asGrid colCnt =
  splitEvery colCnt
  >> List.map (List.intersperse quadDefSpacer >> flow right)
  >> List.intersperse quadDefSpacer
  >> flow down

subjects : List (String, List String)
subjects =
  [ ( "Warm up"
    , [
        "just_type"
      , "delete_chars"
      , "word_swap"
      , "line_swap"
      , "remove_words_1"
      ]
    )
  , ( "Strength"
    , [
        "insert"
      , "new_lines"
      , "remove_words_2"
      , "replace_words"
      , "batman"
      ]
    )
  , ( "Endurance"
    , [
        "numbers"
      , "swap_many_words"
      ]
    )
  , ( "Stretching"
    , [
        "alignment"
      , "more_lines"
      , "i_am_awesome"
      ]
    )
  ]

showSubject : Int -> String -> List String -> Element
showSubject w subject levels =
  let subjectElem = toSizedText 40 subject |> centerHorizontally w
      levelsElem =
        levels
        |> List.map levelButton
        |> asGrid 3
        |> centerHorizontally w
  in flow down [ subjectElem, doubleDefSpacer, levelsElem ]

scene : Int -> Int -> Element
scene w h =
  let paddedDivider = flow down [
                          doubleDefSpacer
                        , divider blue1 w
                        , doubleDefSpacer
                      ]
  in  subjects
        |> List.map (showSubject w |> uncurry)
        |> List.intersperse paddedDivider
        |> flow down
        |> Skeleton.showPage w h
{'fraction_non_alphanumeric': 0.1136260751471254, 'fraction_numerical': 0.012675418741511997, 'mean_word_length': 2.2781899109792283, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 61, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3904179', 'n_tokens_mistral': 1502, 'n_tokens_neox': 1431, 'n_words': 372}