split front and back

This commit is contained in:
Daniel O'Connell 2021-03-06 21:51:42 +01:00
parent c49fc96e72
commit 51ffbb8333
44 changed files with 2968 additions and 434 deletions

18
.gitignore vendored
View File

@ -1,16 +1,14 @@
/out/ /frontend/out/
/resources/public/js/compiled/ /frontend/resources/public/js
/target/ /frontend/resources/public/css
/frontend/target/
/*-init.clj /*-init.clj
/*.log /*.log
# Leiningen
/.lein-*
/.nrepl-port
# Node.js dependencies # Node.js dependencies
/node_modules/ /frontend/node_modules/
# shadow-cljs cache, port files # shadow-cljs cache, port files
/shadow-cljs.edn /frontend/.shadow-cljs/
/.shadow-cljs/
settings

288
README.md
View File

@ -1,288 +0,0 @@
# chicken-master
## TODO
* daily view
* infinite scroll
* Move to different day
* handle regular customers
** every n days
** copy over to next week
** cancel regular order
* settings menu
* products CRM
## Start
docker run --name some-postgres -e POSTGRES_PASSWORD=mysecretpassword -p 5432:5432 -d postgres
A [re-frame](https://github.com/day8/re-frame) application designed to ... well, that part is up to
you.
## Getting Started
### Project Overview
* Architecture:
[Single Page Application (SPA)](https://en.wikipedia.org/wiki/Single-page_application)
* Languages
- Front end ([re-frame](https://github.com/day8/re-frame)): [ClojureScript](https://clojurescript.org/) (CLJS)
- Back end/middleware ([Compojure](https://github.com/weavejester/compojure)): [Clojure](https://clojure.org/)
- CSS compilation ([`lein-garden`](https://github.com/noprompt/lein-garden)): [Clojure](https://clojure.org/)
* Dependencies
- UI framework: [re-frame](https://github.com/day8/re-frame)
([docs](https://github.com/day8/re-frame/blob/master/docs/README.md),
[FAQs](https://github.com/day8/re-frame/blob/master/docs/FAQs/README.md)) ->
[Reagent](https://github.com/reagent-project/reagent) ->
[React](https://github.com/facebook/react)
- Full stack framework: [Compojure](https://github.com/weavejester/compojure)
([Wiki](https://github.com/weavejester/compojure/wiki), [API docs](http://weavejester.github.com/compojure)) ->
[Ring](https://github.com/ring-clojure/ring)
([Wiki](https://github.com/ring-clojure/ring/wiki), [API docs](http://ring-clojure.github.com/ring))
- CSS rendering: [Garden](https://github.com/noprompt/garden)
* Build tools
- Project task & dependency management: [Leiningen](https://github.com/technomancy/leiningen)
- CLJS compilation, REPL, & hot reload: [`shadow-cljs`](https://github.com/thheller/shadow-cljs)
- CSS compilation: [`lein-garden`](https://github.com/noprompt/lein-garden)
* Development tools
- Debugging: [CLJS DevTools](https://github.com/binaryage/cljs-devtools)
- Emacs integration: [CIDER](https://github.com/clojure-emacs/cider)
#### Directory structure
* [`/`](/../../): project config files
* [`dev/`](dev/): source files compiled only with the [dev](#running-the-app) profile
- [`cljs/user.cljs`](dev/cljs/user.cljs): symbols for use during development in the
[ClojureScript REPL](#connecting-to-the-browser-repl-from-a-terminal)
* [`resources/public/`](resources/public/): SPA root directory;
[dev](#running-the-app) / [prod](#production) profile depends on the most recent build
- [`index.html`](resources/public/index.html): SPA home page
- Dynamic SPA content rendered in the following `div`:
```html
<div id="app"></div>
```
- Customizable; add headers, footers, links to other scripts and styles, etc.
- Generated directories and files
- Created on build with either the [dev](#running-the-app) or [prod](#production) profile
- Deleted on `lein clean` (run by all `lein` aliases before building)
- `css/`: compiled CSS (`lein-garden`, can also be
[compiled manually](#compiling-css-with-lein-garden))
- `js/compiled/`: compiled CLJS (`shadow-cljs`)
- Not tracked in source control; see [`.gitignore`](.gitignore)
* [`src/clj/chicken_master/`](src/clj/chicken_master/): Backend and middleware source files (Clojure,
[Compojure](https://github.com/weavejester/compojure))
* [`src/clj/chicken_master/`](src/clj/chicken_master/): CSS compilation source files (Clojure,
[Garden](https://github.com/noprompt/garden))
* [`src/cljs/chicken_master/`](src/cljs/chicken_master/): SPA source files (ClojureScript,
[re-frame](https://github.com/Day8/re-frame))
- [`core.cljs`](src/cljs/chicken_master/core.cljs): contains the SPA entry point, `init`
### Editor/IDE
Use your preferred editor or IDE that supports Clojure/ClojureScript development. See
[Clojure tools](https://clojure.org/community/resources#_clojure_tools) for some popular options.
### Environment Setup
1. Install [JDK 8 or later](https://openjdk.java.net/install/) (Java Development Kit)
2. Install [Leiningen](https://leiningen.org/#install) (Clojure/ClojureScript project task &
dependency management)
3. Install [Node.js](https://nodejs.org/) (JavaScript runtime environment) which should include
[NPM](https://docs.npmjs.com/cli/npm) or if your Node.js installation does not include NPM also install it.
7. Clone this repo and open a terminal in the `chicken-master` project root directory
8. (Optional) Download project dependencies:
```sh
lein deps
```
### Browser Setup
Browser caching should be disabled when developer tools are open to prevent interference with
[`shadow-cljs`](https://github.com/thheller/shadow-cljs) hot reloading.
Custom formatters must be enabled in the browser before
[CLJS DevTools](https://github.com/binaryage/cljs-devtools) can display ClojureScript data in the
console in a more readable way.
#### Chrome/Chromium
1. Open [DevTools](https://developers.google.com/web/tools/chrome-devtools/) (Linux/Windows: `F12`
or `Ctrl-Shift-I`; macOS: `⌘-Option-I`)
2. Open DevTools Settings (Linux/Windows: `?` or `F1`; macOS: `?` or `Fn+F1`)
3. Select `Preferences` in the navigation menu on the left, if it is not already selected
4. Under the `Network` heading, enable the `Disable cache (while DevTools is open)` option
5. Under the `Console` heading, enable the `Enable custom formatters` option
#### Firefox
1. Open [Developer Tools](https://developer.mozilla.org/en-US/docs/Tools) (Linux/Windows: `F12` or
`Ctrl-Shift-I`; macOS: `⌘-Option-I`)
2. Open [Developer Tools Settings](https://developer.mozilla.org/en-US/docs/Tools/Settings)
(Linux/macOS/Windows: `F1`)
3. Under the `Advanced settings` heading, enable the `Disable HTTP Cache (when toolbox is open)`
option
Unfortunately, Firefox does not yet support custom formatters in their devtools. For updates, follow
the enhancement request in their bug tracker:
[1262914 - Add support for Custom Formatters in devtools](https://bugzilla.mozilla.org/show_bug.cgi?id=1262914).
## Development
### Running the App
Start a temporary local web server, build the app with the `dev` profile, and serve the app,
browser test runner and karma test runner with hot reload:
```sh
lein watch
```
Please be patient; it may take over 20 seconds to see any output, and over 40 seconds to complete.
When `[:app] Build completed` appears in the output, browse to
[http://localhost:8280/](http://localhost:8280/).
[`shadow-cljs`](https://github.com/thheller/shadow-cljs) will automatically push ClojureScript code
changes to your browser on save. To prevent a few common issues, see
[Hot Reload in ClojureScript: Things to avoid](https://code.thheller.com/blog/shadow-cljs/2019/08/25/hot-reload-in-clojurescript.html#things-to-avoid).
Opening the app in your browser starts a
[ClojureScript browser REPL](https://clojurescript.org/reference/repl#using-the-browser-as-an-evaluation-environment),
to which you may now connect.
#### Connecting to the browser REPL from Emacs with CIDER
Connect to the browser REPL:
```
M-x cider-jack-in-cljs
```
See
[Shadow CLJS User's Guide: Emacs/CIDER](https://shadow-cljs.github.io/docs/UsersGuide.html#cider)
for more information. Note that the mentioned [`.dir-locals.el`](.dir-locals.el) file has already
been created for you.
#### Connecting to the browser REPL from other editors
See
[Shadow CLJS User's Guide: Editor Integration](https://shadow-cljs.github.io/docs/UsersGuide.html#_editor_integration).
Note that `lein watch` runs `shadow-cljs watch` for you, and that this project's running build ids is
`app`, `browser-test`, `karma-test`, or the keywords `:app`, `:browser-test`, `:karma-test` in a Clojure context.
Alternatively, search the web for info on connecting to a `shadow-cljs` ClojureScript browser REPL
from your editor and configuration.
For example, in Vim / Neovim with `fireplace.vim`
1. Open a `.cljs` file in the project to activate `fireplace.vim`
2. In normal mode, execute the `Piggieback` command with this project's running build id, `:app`:
```vim
:Piggieback :app
```
#### Connecting to the browser REPL from a terminal
1. Connect to the `shadow-cljs` nREPL:
```sh
lein repl :connect localhost:8777
```
The REPL prompt, `shadow.user=>`, indicates that is a Clojure REPL, not ClojureScript.
2. In the REPL, switch the session to this project's running build id, `:app`:
```clj
(shadow.cljs.devtools.api/nrepl-select :app)
```
The REPL prompt changes to `cljs.user=>`, indicating that this is now a ClojureScript REPL.
3. See [`user.cljs`](dev/cljs/user.cljs) for symbols that are immediately accessible in the REPL
without needing to `require`.
### Compiling CSS with `lein-garden`
Use Clojure and [Garden](https://github.com/noprompt/garden) to edit styles in `.clj` files located
in the [`src/clj/chicken_master/`](src/clj/chicken_master/) directory. CSS files are compiled
automatically on [`dev`](#running-the-app) or [`prod`](#production) build.
Manually compile CSS files:
```sh
lein garden once
```
The `resources/public/css/` directory is created, containing the compiled CSS files.
#### Compiling CSS with Garden on change
Enable automatic compiling of CSS files when source `.clj` files are changed:
```sh
lein garden auto
```
### Running `shadow-cljs` Actions
See a list of [`shadow-cljs CLI`](https://shadow-cljs.github.io/docs/UsersGuide.html#_command_line)
actions:
```sh
lein run -m shadow.cljs.devtools.cli --help
```
Please be patient; it may take over 10 seconds to see any output. Also note that some actions shown
may not actually be supported, outputting "Unknown action." when run.
Run a shadow-cljs action on this project's build id (without the colon, just `app`):
```sh
lein run -m shadow.cljs.devtools.cli <action> app
```
### Debug Logging
The `debug?` variable in [`config.cljs`](src/cljs/chicken_master/config.cljs) defaults to `true` in
[`dev`](#running-the-app) builds, and `false` in [`prod`](#production) builds.
Use `debug?` for logging or other tasks that should run only on `dev` builds:
```clj
(ns chicken-master.example
(:require [chicken-master.config :as config])
(when config/debug?
(println "This message will appear in the browser console only on dev builds."))
```
## Production
Build the app with the `prod` profile:
```sh
lein with-profile release uberjar
```
Please be patient; it may take a few seconds to see any output, and over 50 seconds to complete.
The `resources/public/js/compiled` directory is created, containing the compiled `app.js` and
`manifest.edn` files. The `target/` directory is then created, containing the
standalone `chicken-master.jar`.
### Running the Server
[Run the jar](https://github.com/ring-clojure/ring/wiki/Setup-for-production#run-the-server),
setting the port the Ring server will use by setting the environment variable, `port`.
```sh
port=2000 java -jar target/chicken-master.jar
```
If `port` is not set, the server will run on port 3000 by default.
### Deploying to Heroku
1. [Create a Heroku app](https://devcenter.heroku.com/articles/creating-apps):
```sh
heroku create
```
2. [Deploy the app code](https://devcenter.heroku.com/articles/git#deploying-code):
```sh
git push heroku master
```

20
backend/README.md Normal file
View File

@ -0,0 +1,20 @@
## Development
1) Setup the development database:
docker run --name some-postgres -e POSTGRES_PASSWORD=mysecretpassword -p 5432:5432 -d postgres
psql 'postgresql://localhost/postgres?user=postgres&password=mysecretpassword' < resources/schema.sql
2) Start the server:
clojure -M:dev
## Testing
clojure -M:test
## Deployment
clojure -X:depstar uberjar
java -jar chickens.jar -Dconfig=config/dev/config.edn

23
backend/deps.edn Normal file
View File

@ -0,0 +1,23 @@
{:paths ["src" "resources"]
:deps {org.clojure/clojure {:mvn/version "1.10.1"}
ns-tracker {:mvn/version "0.4.0"}
compojure {:mvn/version "1.6.2"}
yogthos/config {:mvn/version "1.1.7"}
seancorfield/next.jdbc {:mvn/version "1.1.613"}
org.postgresql/postgresql {:mvn/version "42.2.6"}
ring-basic-authentication {:mvn/version "1.1.0"}
ring-cors {:mvn/version "0.1.13"}
ring {:mvn/version "1.8.1"}}
:aliases
{:dev {:jvm-opts ["-Dconfig=config/dev/config.edn"]
:main-opts ["-m" "chicken-master.server"]}
:test {:extra-paths ["test"]
:extra-deps {lambdaisland/kaocha {:mvn/version "1.0.732"}}
:main-opts ["-m" "kaocha.runner"]}
:depstar {:replace-deps
{com.github.seancorfield/depstar {:mvn/version "2.0.193"}}
:ns-default hf.depstar
:exec-args {:aot true :jar "chickens.jar" :main-class chicken-master.server}}}}

View File

@ -0,0 +1,7 @@
{;; Networking settings
:port 3000
:allow-origin ["http://localhost:8280" "http://localhost:3000"]
;; db settings
:db-uri {:jdbcUrl "jdbc:postgresql://localhost/postgres?user=postgres&password=mysecretpassword"}
}

View File

@ -9,11 +9,14 @@
{:headers {"Content-Type" "application/edn"} {:headers {"Content-Type" "application/edn"}
:body resp}) :body resp})
(defn get-values [user-id kinds] (defn- values-for-kind [user-id kind]
(let [getters {:customers customers/get-all (when-let [getter ({:customers customers/get-all
:products products/get-all :products products/get-all
:order orders/get-all}] :orders orders/get-all} kind)]
(as-edn (reduce #(assoc %1 %2 ((getters %2) user-id)) {} kinds)))) (getter user-id)))
(defn get-values [user-id kinds]
(as-edn (reduce #(assoc %1 %2 (values-for-kind user-id %2)) {} kinds)))
(defn get-customers [user-id] (get-values user-id [:customers])) (defn get-customers [user-id] (get-values user-id [:customers]))
(defn add-customer [{:keys [body basic-authentication]}] (defn add-customer [{:keys [body basic-authentication]}]
@ -26,7 +29,7 @@
(defn save-products [{:keys [body basic-authentication]}] (defn save-products [{:keys [body basic-authentication]}]
(some->> body (products/update! basic-authentication) (assoc {} :products) as-edn)) (some->> body (products/update! basic-authentication) (assoc {} :products) as-edn))
(defn get-orders [user-id] (get-values user-id [:orders])) (defn get-orders [user-id] (as-edn (orders/get-all user-id)))
(defn update-order [request] (defn update-order [request]
(let [user-id (:basic-authentication request) (let [user-id (:basic-authentication request)
id (some-> request :route-params :id (Integer/parseInt)) id (some-> request :route-params :id (Integer/parseInt))

View File

@ -10,7 +10,7 @@
(defn upsert-order! [tx user-id customer-id {:keys [id day state notes]}] (defn upsert-order! [tx user-id customer-id {:keys [id day state notes]}]
(let [order {:customer_id customer-id (let [order {:customer_id customer-id
:notes notes :notes notes
:status (some-> state name jdbc.types/as-other) :status (some-> (or state "waiting") name jdbc.types/as-other)
:order_date (some-> day t/parse-date t/inst->timestamp)}] :order_date (some-> day t/parse-date t/inst->timestamp)}]
(if (db/get-by-id tx user-id :orders id) (if (db/get-by-id tx user-id :orders id)
(do (sql/update! tx :orders order {:id id}) id) (do (sql/update! tx :orders order {:id id}) id)

View File

@ -1,9 +1,8 @@
(ns clj.chicken-master.customers-test (ns chicken-master.customers-test
(:require (:require
[next.jdbc :as jdbc] [next.jdbc :as jdbc]
[next.jdbc.sql :as sql] [next.jdbc.sql :as sql]
[chicken-master.customers :as sut] [chicken-master.customers :as sut]
[chicken-master.orders :as orders]
[clojure.test :refer [deftest is testing]])) [clojure.test :refer [deftest is testing]]))
(deftest test-get-all (deftest test-get-all
@ -15,22 +14,12 @@
(testing "results are mapped correctly" (testing "results are mapped correctly"
(with-redefs [sql/query (constantly [{:customers/id 1 :customers/name "mr blobby" :bla 123}])] (with-redefs [sql/query (constantly [{:customers/id 1 :customers/name "mr blobby" :bla 123}])]
(= (sut/get-all "1") (is (= (sut/get-all "1")
[{:id 1 :name "mr blobby"}])))) [{:id 1 :name "mr blobby"}])))))
(deftest test-create! (deftest test-create!
(testing "correct format is returned" (testing "correct format is returned"
(with-redefs [jdbc/execute! (constantly []) (with-redefs [jdbc/execute! (constantly [])
sql/query (constantly [{:customers/id 1 :customers/name "mr blobby" :bla 123}])] sql/query (constantly [{:customers/id 1 :customers/name "mr blobby" :bla 123}])]
(= (sut/create! "1" "mr blobby") (is (= (sut/create! "1" "mr blobby")
{:customers [{:id 1 :name "mr blobby"}]})))) {:customers [{:id 1 :name "mr blobby"}]})))))
(deftest test-delete!
(testing "correct format returned"
(with-redefs [orders/get-all (constantly :orders)
sql/update! (constantly [])
sql/query (constantly [{:customers/id 1 :customers/name "mr blobby" :bla 123}])]
(= (sut/delete! "1" "2")
{:customers [{:id 1 :name "mr blobby"}]
:orders :orders}))))

View File

@ -1,4 +1,4 @@
(ns clj.chicken-master.orders-test (ns chicken-master.orders-test
(:require (:require
[next.jdbc :as jdbc] [next.jdbc :as jdbc]
[next.jdbc.sql :as sql] [next.jdbc.sql :as sql]

View File

@ -1,4 +1,4 @@
(ns clj.chicken-master.products-test (ns chicken-master.products-test
(:require (:require
[next.jdbc :as jdbc] [next.jdbc :as jdbc]
[next.jdbc.sql :as sql] [next.jdbc.sql :as sql]

34
frontend/README.md Normal file
View File

@ -0,0 +1,34 @@
## Development
Start the server:
clojure -A:shadow-cljs watch frontend
or
npx shadow-cljs watch frontend
The app will be available at http://localhost:8280/
## Stylesheets
Run `clojure -A:garden -m chicken-master.css` to generate the css files.
## Testing
Setup Karma:
npm install karma karma-cljs-test --save-dev
npm install karma-chrome-launcher --save-dev
sudo npm install -g karma-cli
Compile the code:
npx shadow-cljs compile ci
Start the tester:
karma start
If the tests are only to be run once, use `karma start --single-run`

17
frontend/deps.edn Normal file
View File

@ -0,0 +1,17 @@
{:paths ["src"]
:deps {reagent/reagent {:mvn/version "1.0.0"}
re-frame/re-frame {:mvn/version "1.2.0"}
day8.re-frame/http-fx {:mvn/version "0.2.3"}}
:aliases
{:shadow-cljs
{:extra-deps {thheller/shadow-cljs {:mvn/version "2.11.21"}}
:main-opts ["-m" "shadow.cljs.devtools.cli"]}
:garden
{:extra-deps {garden/garden {:mvn/version "1.3.10"}}}
:test {:extra-paths ["test"]
:extra-deps {}}
:test-run {:extra-deps {}
:main-opts ["-m" "test" "test" "*"]}}}

17
frontend/karma.conf.js Normal file
View File

@ -0,0 +1,17 @@
module.exports = function (config) {
config.set({
browsers: ['ChromeHeadless'],
// The directory where the output file lives
basePath: 'target',
// The file itself
files: ['ci.js'],
frameworks: ['cljs-test'],
plugins: ['karma-cljs-test', 'karma-chrome-launcher'],
colors: true,
logLevel: config.LOG_INFO,
client: {
args: ["shadow.test.karma.init"],
singleRun: true
}
});
};

2604
frontend/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

19
frontend/package.json Normal file
View File

@ -0,0 +1,19 @@
{
"name": "frontend",
"version": "0.0.1",
"private": true,
"devDependencies": {
"jasmine-core": "^3.6.0",
"karma": "^6.1.1",
"karma-chrome-launcher": "^3.1.0",
"karma-cljs-test": "^0.1.0",
"karma-firefox-launcher": "^2.1.0",
"karma-jasmine": "^4.0.1",
"karma-phantomjs-launcher": "^1.0.4",
"shadow-cljs": "2.11.20"
},
"dependencies": {
"react": "17.0.1",
"react-dom": "17.0.1"
}
}

View File

@ -11,6 +11,6 @@
chicken-master is a JavaScript app. Please enable JavaScript to continue. chicken-master is a JavaScript app. Please enable JavaScript to continue.
</noscript> </noscript>
<div id="app"></div> <div id="app"></div>
<script src="js/compiled/app.js"></script> <script src="js/app.js"></script>
</body> </body>
</html> </html>

32
frontend/shadow-cljs.edn Normal file
View File

@ -0,0 +1,32 @@
{
:source-paths ["src" "test"]
:dependencies [[reagent "1.0.0"]
[re-frame "1.2.0"]
[day8.re-frame/http-fx "0.2.2"]
[cider/cider-nrepl "0.25.9"]
[garden/garden "1.3.10"]]
:builds
{:frontend {:target :browser
:output-dir "resources/public/js"
:asset-path "/js"
:modules {:app {:init-fn chicken-master.core/init}}
:devtools {:http-root "resources/public" :http-port 8280}}
:test {:target :browser-test
:test-dir "resources/public/js/test"
:ns-regexp "-test$"
:devtools {:http-port 8021
:http-root "resources/public/js/test"}}
:ci {:target :karma
:test-dir "resources/public/js/test"
:output-to "target/ci.js"
:ns-regexp "-test$"}
:script
{:target :node-script
:main demo.script/main
:output-to "out/demo-script/script.js"}
}}

View File

@ -101,7 +101,6 @@
(into []))) (into [])))
(defn calendar [days settings] (defn calendar [days settings]
(html/modal :settings [:div "asd"])
(->> days (->> days
(map (partial day settings)) (map (partial day settings))
(concat (when (settings :calendar-heading) (calendar-header settings))) (concat (when (settings :calendar-heading) (calendar-header settings)))

View File

@ -4,9 +4,7 @@
[re-frame.core :as re-frame] [re-frame.core :as re-frame]
[chicken-master.events :as events] [chicken-master.events :as events]
[chicken-master.views :as views] [chicken-master.views :as views]
[chicken-master.config :as config] [chicken-master.config :as config]))
))
(defn dev-setup [] (defn dev-setup []
(when config/debug? (when config/debug?

View File

@ -0,0 +1,166 @@
(ns chicken-master.css
(:require [garden.def :refer [defstyles]]
[garden.core :refer [css]]
[garden.stylesheet :refer [at-media at-keyframes]]))
(defstyles screen
(at-keyframes "spin"
[:0% {:transform "rotate(0deg)"}]
[:100% {:transform "rotate(360deg)"}])
[:html {:height "100%"}
[:body {:height "100%"}
[:.hidden {:display :none}]
[:.loader-container {:position :absolute
:width "100%"
:height "100%"
:z-index 1000
:background-color "rgba(0,0,0,0.4)"
}
[:.loader {:margin :auto
:position :relative
:top "40%"
:border "5px solid #f3f3f3"; /* Light grey */
:border-top "5px solid #3498db"; /* Blue */
:border-radius "50%";
:width "30px"
:height "30px"
:animation "spin 1s linear infinite"}]]
[:.full-height {:height "100%"}]
[:.scroll-bar {:position :absolute
:right "10px"
:width "50px"}
[:#scroll-down {:position :fixed
:right "0"
:bottom "0"}]]
[:.popup {:position :fixed
:height "100%"
:width "100%"
:overflow :auto
:z-index 1
:background-color "rgba(0,0,0,0.4)"}
[:.popup-content {
:background-color "#fefefe"
:margin "15% auto"
:padding "20px"
:border "1px solid #888"
:width "15%"
}
[:.input-item
[:label {:min-width "60px"
:display :inline-block}]]
[:..popup-form-buttons {:margin "10px"}
[:* {:margin "20px"}]]]]
[:.scroll-button {:display :none}]
(at-media
{:max-width "800px"}
[:.scroll-bar {:display :none}]
[:.menu-button {:width "100%"
:font-size "3em"
:display :inherit}]
[:.popup
[:.popup-content {
:background-color "#fefefe"
:margin "3% auto"
:padding "20px"
:border "1px solid #888"
:width "60%"}
[:.product-items-edit {:margin-top "1.5em"}
[:.product-item-edit
[:label {:display :none}]]]]]
[:.calendar
[:.day {:min-height "12em"}]
])
(at-media
{:min-width "800px"}
[:.popup
[:.popup-content {
:background-color "#fefefe"
:margin "15% auto"
:padding "20px"
:border "1px solid #888"
:width "15%"
}]]
[:.calendar {:display :grid
:grid-template-columns "25% 25% 25% 25%"
:grid-template-rows "50% 50%"}])
(at-media {:min-width "1200px"}
[:.calendar
{:display :grid
:grid-template-columns "14% 14% 14% 14% 14% 14% 14%"
:grid-template-rows "50% 50%"}])
[:.calendar
[:.day-header {:border "2px solid black"
:text-align :center
:font-size "2em"}]
[:.day.today {:border "0.4em solid red"}]
[:.day {:border "2px solid black"
:overflow :auto}
; If each day has a header, then hide the rest of the border
[:.day-header {:border "none"
:border-bottom "2px solid black"}]
[:.orders {:padding-left "25px"}
[:.actions {:display :none
:float :right}]
[:.order:hover [:.actions {:display :inline}]]
[:.order.pending {:color :grey}]
[:.order.fulfilled {:color :red}]
[:.who {:font-size "18px"
:font-weight :bold
:white-space :nowrap
:overflow :hidden
:text-overflow :ellipsis}]]
[[:.products :.products-sum] {:padding-left "25px"}
[:.product {:margin-bottom "5px"}
[:.product-name {:width "5em"
:display :inline-block
:text-overflow :ellipsis
:white-space :nowrap
:overflow :hidden
:margin-right "10px"}]
[:.product-amount {:width "40px"
:max-height "5px"}]
]]
[:.summary {:margin-top "10px"}]]]
[:.stock-modal
[:.add-product {:float :right}]
[:.stock-product {:margin "1em 0"}
[:.product-name {:display :inline-block
:width "6em"}]
[:.stock-product-amount {:display :inline-block}
[:.input-item {:display :inline}
[:input {:width "40px"}]
[:label {:display :none}]]
]]
]
[:.customers-modal
[:details {:padding "0.5em"}]
[:details.customer-order {:margin-left "1em" :padding "0.5em"}
[:.order-date-picker {:display :inline-block :width "75%" :cursor :pointer}]
[:.product-item-edit {:margin-left "1em"}]]]
]]
; Chrome, Safari, Edge, Opera
["input::-webkit-outer-spin-button" {:-webkit-appearance :none :margin 0}]
["input::-webkit-inner-spin-button"{:-webkit-appearance :none :margin 0}]
; Firefox
["input[type=number]" {:-moz-appearance :textfield}]
)
(defn -main
([] (-main "resources/public/css/screen.css"))
([output] (css {:output-to output} screen)))

View File

@ -1,8 +1,7 @@
(ns chicken-master.sutendar-test (ns chicken-master.calendar-test
(:require (:require
[chicken-master.calendar :as sut] [chicken-master.calendar :as sut]
[cljs.test :refer-macros [deftest is testing run-tests]])) [cljs.test :refer-macros [deftest is testing]]))
(deftest format-raw-order-test (deftest format-raw-order-test
(testing "no products" (testing "no products"
@ -44,4 +43,3 @@
"product-cow" "cow" "amount-cow" "0" "product-cow" "cow" "amount-cow" "0"
"product-milk" "milk" "amount-milk" "3.2"}) "product-milk" "milk" "amount-milk" "3.2"})
{:who {:name "bla" :id 123} :notes "ble" :products {:eggs 12 :milk 3.2}})))) {:who {:name "bla" :id 123} :notes "ble" :products {:eggs 12 :milk 3.2}}))))
(run-tests)

View File

@ -1,8 +1,7 @@
(ns chicken-master.products-test (ns chicken-master.products-test
(:require (:require
[chicken-master.products :as sut] [chicken-master.products :as sut]
[cljs.test :refer-macros [deftest is testing run-tests]])) [cljs.test :refer-macros [deftest is testing]]))
(deftest test-num-or-nil (deftest test-num-or-nil
(testing "valid integers" (testing "valid integers"
@ -40,5 +39,3 @@
[:div {:class :input-item} [:div {:class :input-item}
[:label {:for :id} :label] [:label {:for :id} :label]
[:input {:type :number :step :any :on-blur nil :defaultValue 12.123 :name :id :id :id}]])))) [:input {:type :number :step :any :on-blur nil :defaultValue 12.123 :name :id :id :id}]]))))
(run-tests)

View File

@ -1,98 +0,0 @@
(defproject chicken-master "0.1.0-SNAPSHOT"
:dependencies [[org.clojure/clojure "1.10.1"]
[org.clojure/clojurescript "1.10.773"
:exclusions [com.google.javascript/closure-compiler-unshaded
org.clojure/google-closure-library
org.clojure/google-closure-library-third-party]]
[thheller/shadow-cljs "2.11.0"]
[reagent "0.10.0"]
[re-frame "1.1.1"]
[day8.re-frame/http-fx "0.2.2"]
[garden "1.3.10"]
[ns-tracker "0.4.0"]
[compojure "1.6.2"]
[yogthos/config "1.1.7"]
[seancorfield/next.jdbc "1.1.613"]
[org.postgresql/postgresql "42.2.6"]
[ring-basic-authentication "1.1.0"]
[ring-cors "0.1.13"]
[ring "1.8.1"]]
:plugins [[lein-shadow "0.2.2"]
[lein-garden "0.3.0"]
[lein-shell "0.5.0"]]
:min-lein-version "2.9.0"
:jvm-opts ["-Xmx1G" "-Dconfig=config/dev/config.edn"]
:source-paths ["src/clj" "src/cljs"]
:clean-targets ^{:protect false} ["resources/public/js/compiled" "target"
"resources/public/css"]
:garden {:builds [{:id "screen"
:source-paths ["src/clj"]
:stylesheet chicken-master.css/screen
:compiler {:output-to "resources/public/css/screen.css"
:pretty-print? true}}]}
:shadow-cljs {:nrepl {:port 8777}
:builds {:app {:target :browser
:output-dir "resources/public/js/compiled"
:asset-path "/js/compiled"
:modules {:app {:init-fn chicken-master.core/init
:preloads [devtools.preload]}}
:devtools {:http-root "resources/public"
:http-port 8280
:http-handler chicken-master.handler/dev-handler
}}}}
:shell {:commands {"karma" {:windows ["cmd" "/c" "karma"]
:default-command "karma"}
"open" {:windows ["cmd" "/c" "start"]
:macosx "open"
:linux "xdg-open"}}}
:aliases {"dev" ["do"
["shell" "echo" "\"DEPRECATED: Please use lein watch instead.\""]
["watch"]]
"watch" ["with-profile" "dev" "do"
["shadow" "watch" "app" "browser-test" "karma-test"]]
"prod" ["do"
["shell" "echo" "\"DEPRECATED: Please use lein release instead.\""]
["release"]]
"release" ["with-profile" "prod" "do"
["shadow" "release" "app"]]
"build-report" ["with-profile" "prod" "do"
["shadow" "run" "shadow.cljs.build-report" "app" "target/build-report.html"]
["shell" "open" "target/build-report.html"]]
"karma" ["do"
["shell" "echo" "\"DEPRECATED: Please use lein ci instead.\""]
["ci"]]
"ci" ["with-profile" "prod" "do"
["shadow" "compile" "karma-test"]
["shell" "karma" "start" "--single-run" "--reporters" "junit,dots"]]}
:profiles
{:dev
{:dependencies [[binaryage/devtools "1.0.2"]]
:source-paths ["config/dev"]}
:prod {:resource-paths ["config/prod"]}
:uberjar {:source-paths ["env/prod/clj"]
:omit-source true
:main chicken-master.server
:aot [chicken-master.server]
:uberjar-name "chicken-master.jar"
:prep-tasks ["compile" ["prod"]["garden" "once"]]}}
:prep-tasks [["garden" "once"]])

View File

@ -1 +0,0 @@
{:npm-dev-deps {"shadow-cljs" "2.11.0"}}