initial commit
This commit is contained in:
52
generator/templateExampleApp/src/App.purs
Normal file
52
generator/templateExampleApp/src/App.purs
Normal file
@@ -0,0 +1,52 @@
|
||||
module App where
|
||||
|
||||
import Prelude
|
||||
import Effect (Effect)
|
||||
import Effect.Unsafe (unsafePerformEffect)
|
||||
import Effect.Vue.Ref as Ref
|
||||
import Effect.Vue.Hooks as Hooks
|
||||
import Effect.Class.Console (logShow)
|
||||
import Data.Array (snoc)
|
||||
|
||||
|
||||
type Product = { id :: Int, title :: String, price :: Number }
|
||||
createProduct :: Array Product -> Int -> String -> Number -> Array Product
|
||||
createProduct products id title price = snoc products { id, title, price }
|
||||
|
||||
execCreateProduct :: Ref.Ref (Array Product) -> String -> Number -> Effect Unit
|
||||
execCreateProduct products title price = do
|
||||
p <- Ref.read products
|
||||
let p' = createProduct p 42 title (23.666)
|
||||
Ref.write p' products
|
||||
|
||||
incRelease :: Ref.Ref Int -> Effect Unit
|
||||
incRelease release = Ref.modify_ (\x -> x + 1) release
|
||||
|
||||
compTest :: Ref.Ref Int -> Effect Int
|
||||
compTest release = do
|
||||
r <- Ref.read release
|
||||
pure (r + 1)
|
||||
|
||||
type Props = {}
|
||||
|
||||
setup :: forall a. Props -> Effect a
|
||||
setup props = unsafePerformEffect do
|
||||
products :: Ref.Ref (Array Product) <- Ref.new []
|
||||
showUserInfo <- Ref.new false
|
||||
release <- Ref.new 9
|
||||
|
||||
computedTest <- Ref.computed $ compTest release
|
||||
|
||||
Hooks.onMounted mounted
|
||||
|
||||
Ref.vReturn { products
|
||||
, showUserInfo
|
||||
, release
|
||||
, computedTest
|
||||
, incRelease: (incRelease release)
|
||||
, addProduct: (execCreateProduct products)
|
||||
}
|
||||
|
||||
mounted :: Effect Unit
|
||||
mounted = do
|
||||
logShow "estasetase"
|
||||
31
generator/templateExampleApp/src/App.vue
Normal file
31
generator/templateExampleApp/src/App.vue
Normal file
@@ -0,0 +1,31 @@
|
||||
<template>
|
||||
<div>
|
||||
<button
|
||||
target="_blank"
|
||||
@click="incRelease(); addProduct('mytit')(32)();"
|
||||
/>
|
||||
<span class="mr-2">Latest Release {{ release }}</span>
|
||||
|
||||
ctest - {{ computedTest }} -
|
||||
<privacy-policy
|
||||
:release="42"
|
||||
></privacy-policy>
|
||||
<!--router-view
|
||||
:release="release"
|
||||
></router-view-->
|
||||
{{ products }}
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { setup } from '@/App.purs'
|
||||
import PrivacyPolicy from './views/PrivacyPolicy'
|
||||
|
||||
export default {
|
||||
name: 'App',
|
||||
components: {
|
||||
PrivacyPolicy,
|
||||
},
|
||||
setup
|
||||
};
|
||||
</script>
|
||||
24
generator/templateExampleApp/src/views/PrivacyPolicy.purs
Normal file
24
generator/templateExampleApp/src/views/PrivacyPolicy.purs
Normal file
@@ -0,0 +1,24 @@
|
||||
module PrivacyPolicy where
|
||||
|
||||
import Prelude
|
||||
import Effect (Effect)
|
||||
import Effect.Unsafe (unsafePerformEffect)
|
||||
import Effect.Vue.Ref as Ref
|
||||
import Record.Extra as Record
|
||||
import Data.Array as Arr
|
||||
import Type.Row (RProxy(..))
|
||||
|
||||
type Props = ( release :: Int )
|
||||
|
||||
-- this to lib
|
||||
-- type RecordProps = Record.Record Props
|
||||
props = Record.keys (RProxy :: RProxy Props)
|
||||
|
||||
privacyPolicy :: String -> String
|
||||
privacyPolicy policyRaw = policyRaw
|
||||
|
||||
buildSetup :: forall a. String -> _ -> Effect a
|
||||
buildSetup policyRaw props = unsafePerformEffect do
|
||||
dialog <- Ref.new true
|
||||
|
||||
Ref.vReturn { dialog, privacyPolicy: privacyPolicy policyRaw }
|
||||
31
generator/templateExampleApp/src/views/PrivacyPolicy.vue
Normal file
31
generator/templateExampleApp/src/views/PrivacyPolicy.vue
Normal file
@@ -0,0 +1,31 @@
|
||||
<template>
|
||||
<v-container>
|
||||
<v-layout>
|
||||
<v-card>
|
||||
<v-card-title
|
||||
class="headline grey lighten-2"
|
||||
primary-title
|
||||
>
|
||||
Privacy Policy r {{ release }}
|
||||
</v-card-title>
|
||||
|
||||
<v-card-text v-html="privacyPolicy()">
|
||||
</v-card-text>
|
||||
</v-card>
|
||||
</v-layout>
|
||||
</v-container>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { buildSetup, props } from '@/views/PrivacyPolicy.purs'
|
||||
|
||||
export default {
|
||||
name: 'PrivacyPolicy',
|
||||
props,
|
||||
setup: buildSetup('myprvipolicy'),
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
</style>
|
||||
Reference in New Issue
Block a user