Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: components-first-release #7

Merged
merged 37 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
af8e810
feat: building .jar
Felipe-gsilva Sep 9, 2024
7781d6f
doc: enhance installation process
Felipe-gsilva Sep 9, 2024
657cd4b
feat: creating node library (unfinished)
Felipe-gsilva Sep 11, 2024
15826a9
fix: node-lib building config
Felipe-gsilva Sep 12, 2024
84ff0fa
doc: code rabbit snippets
Felipe-gsilva Sep 12, 2024
aefd082
fix: glob, rimraf and cliui deps
Felipe-gsilva Sep 12, 2024
207a668
fix: adds prop test unit (back)
Felipe-gsilva Sep 12, 2024
73ab5c5
feat: mockingbird as npm-module
Felipe-gsilva Sep 12, 2024
5c550a6
fix: comma on package.json
Felipe-gsilva Sep 12, 2024
9b58fd2
feat: adds webpack config
Felipe-gsilva Sep 17, 2024
cccbe1a
chore: webpack and npm module config
Felipe-gsilva Sep 18, 2024
7cd6fed
feat: build jar back and gh releases
Felipe-gsilva Sep 18, 2024
f8100cc
fix: minor issues
Felipe-gsilva Sep 18, 2024
33477ad
fix: testing compiling options
Felipe-gsilva Sep 20, 2024
8edc81c
test: exporting fn button
Felipe-gsilva Sep 23, 2024
ee3a393
feat: diff prod and dev on webpack bundle
J0sueTM Sep 23, 2024
e48e40a
Update webpack.config.js
avelino Sep 23, 2024
99e1d8c
feat: submit button
Felipe-gsilva Sep 24, 2024
8baba22
feat: loading prop and fixes on example page
Felipe-gsilva Sep 24, 2024
cbd05c4
doc: updates README.md for clojar and new usage
Felipe-gsilva Sep 25, 2024
eb13794
docs: improves text cohesion
Felipe-gsilva Sep 25, 2024
c72bf5a
feat: enhance on navbar
Felipe-gsilva Sep 25, 2024
f5ff6b6
feat: better compiling on css and component enhancement
Felipe-gsilva Sep 25, 2024
f541320
feat: copy the css file from .jar (on build hook)
Felipe-gsilva Sep 27, 2024
c6d97bf
fix: css build hook
Felipe-gsilva Sep 28, 2024
dfc1798
fix: unit test for props
Felipe-gsilva Sep 28, 2024
935f48b
feat: copy target.css on any project to a specified path
Felipe-gsilva Sep 30, 2024
7dc6e58
fix: formatting
Felipe-gsilva Sep 30, 2024
2f3e319
fix: gray-50 color error
Felipe-gsilva Oct 1, 2024
ca98734
fix: button, input and props fix
Felipe-gsilva Oct 1, 2024
0c84712
fix: props test
Felipe-gsilva Oct 1, 2024
1987956
fix: component style enhance
Felipe-gsilva Oct 2, 2024
efd5257
fix: ci workflow
Felipe-gsilva Oct 3, 2024
46df98a
fix: npm install
Felipe-gsilva Oct 3, 2024
4dc125b
docs: improve reading flow
Felipe-gsilva Oct 4, 2024
bf83370
doc: adds more context on README.md
Felipe-gsilva Oct 4, 2024
ff9a234
feat: export tag for shadow npm compiling
Felipe-gsilva Oct 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Release

on:
push:
tags:
- 'v*'
workflow_dispatch:
Comment on lines +1 to +7
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

LGTM! The workflow name and triggers are well-defined.

The workflow name "Release" is clear and descriptive. The triggers are appropriate for a release workflow, allowing for both automated releases on version tags and manual triggering.

Consider adding a brief description comment at the beginning of the file to provide more context:

# Workflow for releasing the project to Clojars
# Triggered on pushing tags starting with 'v' or manually
name: Release
🧰 Tools
🪛 yamllint

[warning] 3-3: truthy value should be one of [false, true]

(truthy)


[error] 5-5: wrong indentation: expected 8 but found 6

(indentation)


[error] 6-6: wrong indentation: expected 10 but found 8

(indentation)


jobs:
clojars:
runs-on: ubuntu-latest
environment: release
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4
- uses: "DeLaGuardo/[email protected]"
with:
cli: "1.11.1.1139"
- name: release
env:
CLOJARS_USERNAME: ${{ secrets.CLOJARS_USERNAME }}
CLOJARS_PASSWORD: ${{ secrets.CLOJARS_PASSWORD }}
run: |
clojure -T:dev:build clean && \
clojure -T:dev:build jar && \
clojure -X:deploy-clojars

Felipe-gsilva marked this conversation as resolved.
Show resolved Hide resolved
Felipe-gsilva marked this conversation as resolved.
Show resolved Hide resolved
29 changes: 20 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,31 +24,42 @@ Prerequisites

Before you begin, ensure you have the following installed:
- Clojure: Follow the [Clojure Installation guide](https://clojure.org/guides/install_clojure) to set up your environment.
- Node.js: Required for managing dependencies and building your project. Download it from [here](https://www.npmjs.com/package/downloads).
- [Node.js](https://nodejs.org/en/download/prebuilt-installer/current).
- [npm](https://www.npmjs.com/package/downloads).

# Installation

- Set up your project: Start by creating a new ClojureScript project, or use an existing one.
We distribute our software via Clojars, so you are able to just plug and play!
Felipe-gsilva marked this conversation as resolved.
Show resolved Hide resolved

- Install node dependencies with a simple command:
``` clj

``` sh
npm i
```
;; TODO

- configure your shadow cljs:
```

> for better understanding, follow the offcial [guide](https://github.com/thheller/shadow-cljs)


# Usage

;; TODO

# Testing

# Testing Locally

And you are now done, you can clone and build this repo in order to see some examples of good usage of our dear Mockingbird. You can read more [here](docs/test.md).
Felipe-gsilva marked this conversation as resolved.
Show resolved Hide resolved

- Set up your project: Start by creating a new ClojureScript project, or use an existing one.

- Install node dependencies with a simple command:

``` sh
npm i
```
Felipe-gsilva marked this conversation as resolved.
Show resolved Hide resolved

- configure your shadow cljs

> for better understanding, follow the offcial [guide](https://github.com/thheller/shadow-cljs)

# Contributing

Mockingbird is open-source, and contributions are welcome! If you have ideas for new features, improvements, or bug fixes, feel free to open an issue or submit a pull request.
30 changes: 30 additions & 0 deletions build.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
(ns build
(:require [clojure.tools.build.api :as b]))

(def lib 'com.github.moclojer/mockingbird)
(def version "0.0.1")
Felipe-gsilva marked this conversation as resolved.
Show resolved Hide resolved
(def class-dir "target/classes")
(def basis (b/create-basis {:project "deps.edn"}))
(def jar-file (format "target/%s-%s.jar" (name lib) version))
Comment on lines +5 to +9
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Consider Centralizing the Version Number

The version number "0.0.1" is hardcoded in multiple files (build.clj, package.json, and package-lock.json). To enhance maintainability and ensure consistency across the project, consider implementing a centralized version management system for future releases.

🔗 Analysis chain

LGTM: Project metadata definitions are correct

The project metadata definitions look good for a first release. However, for future releases, consider implementing a more flexible version management system.

To ensure consistency across the project, let's verify if the version is used elsewhere:


To accurately verify if the version number "0.0.1" is used elsewhere in the codebase, please run the following script:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for other occurrences of the version number
rg --type-add 'json:*.json' --type-add 'edn:*.edn' --type json,edn,clojure '"0.0.1"'

Length of output: 127


Script:

# 
#!/bin/bash
# Description: Check for other occurrences of the version number
rg -tjson -tedn -tclojure '"0.0.1"'

Length of output: 470


(defn clean [_]
(b/delete {:path "target"}))

(defn jar [_]
(b/write-pom {:class-dir class-dir
:lib lib
:version version
:basis basis
:src-dirs ["src"]})
(b/copy-dir {:src-dirs ["src" "resources"]
:target-dir class-dir})
(b/jar {:class-dir class-dir
:jar-file jar-file}))
Felipe-gsilva marked this conversation as resolved.
Show resolved Hide resolved

(defn install [_]
(b/install {:basis basis
:lib lib
:version version
:jar-file jar-file
:class-dir class-dir}))

13 changes: 12 additions & 1 deletion deps.edn
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{:paths ["src" "resources"]
:deps {org.clojure/clojure {:mvn/version "1.11.1"}
org.clojure/clojurescript {:mvn/version "1.11.4"}
com.fbeyer/refx {:mvn/version "0.0.49"}
lilactown/helix {:mvn/version "0.1.9"}
funcool/promesa {:mvn/version "9.0.494"}
Expand All @@ -15,4 +16,14 @@
:clojure-lsp {:replace-deps {com.github.clojure-lsp/clojure-lsp-standalone {:mvn/version "2024.08.05_18.16.00-1"}}
:main-opts ["-m" "clojure-lsp.main"]}
:build {:deps {io.github.clojure/tools.build {:mvn/version "0.9.4"}}
:ns-default build}}}
:ns-default build}

;; clj -M:dev --report stderr -m com.moclojer.tools.build
;; env CLOJARS_USERNAME=username CLOJARS_PASSWORD=clojars-token
;; clj -X:deploy-clojars
:deploy-clojars {:extra-deps {slipset/deps-deploy {:mvn/version (build/version)}}
:exec-fn deps-deploy.deps-deploy/deploy
:exec-args {:installer :remote
:sign-releases? false
:pom-file "target/classes/META-INF/maven/com.moclojer/mockingbird/pom.xml"
:artifact "target/com.moclojer.mockingbird.jar"}}}}
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@
"ci:tests": "npm run ci:karma-make && npx shadow-cljs compile ci-tests && npx karma start --single-run",
"postcss:build": "npx cross-env TAILWIND_MODE=build postcss src/mockingbird/css/tailwind.css -o ./resources/public/assets/css/output.css --verbose",
"postcss:watch": "npx cross-env TAILWIND_MODE=watch postcss src/mockingbird/css/tailwind.css -o ./resources/public/assets/css/output.css --verbose -w",
"app:watch": "npx shadow-cljs watch app",
"watch": "run-p -l *:watch",
"repl": "npx shadow-cljs clj-repl"
"watch": "npx shadow-cljs watch app",
Felipe-gsilva marked this conversation as resolved.
Show resolved Hide resolved
"repl": "npx shadow-cljs clj-repl",
"release": "run-s shadow:release",
"shadow:release": "npx shadow-cljs release app"
},
"dependencies": {
"@codemirror/language": "^6.6.0",
Expand Down
42 changes: 15 additions & 27 deletions src/mockingbird/components/aside.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -9,39 +9,23 @@
[refx.alpha :as refx]
[reitit.frontend.easy :as rfe]))

#_(defnc mock []
(let [aside (refx/use-sub [:app.dashboard/aside])
aside-open? (:open? aside)
current-user (refx/use-sub [:app.auth/current-user])
menu-open? (refx/use-sub [:app.dashboard/is-menu-open?])
mocks-raw (refx/use-sub [:app.dashboard/mocks-raw])]

(hooks/use-effect
[mocks-raw]
(when (nil? mocks-raw)
(refx/dispatch-sync [:app.dashboard/get-mocks current-user])))

;; TODO add mock content
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Address the TODO: Add mock content

The TODO comment indicates that mock content needs to be added to the mock component. Would you like assistance in implementing this content, or should we open a GitHub issue to track this task?

(defnc mock [{:keys [aside aside-open?
current-user menu-open?
mocks-raw when-mock-raw
children]
:or {aside "" aside-open? false
current-user "" menu-open? false
mocks-raw false when-mock-raw ""}}]
(d/li
(d/div
{:class "flex flex-row"}
(d/button
{:on-click #(rfe/push-state :app.core/mocks)
:class (str "flex items-center p-2 w-full text-base font-normal text-gray-900 rounded-lg "
"transition duration-75 group hover:bg-gray-100 dark:text-gray-200 dark:hover:bg-gray-700 ")
:aria-controls "dropdown-mocks"
:aria-expanded aside-open?
:data-collapse-toggle "dropdown-mocks"}
(d/span {:class (str "flex ml-3 text-left whitespace-nowrap "
(when-not aside-open?
"lg:absolute lg:hidden"))} "Mocks"))
(d/button
{:class (str "px-2 rounded-lg fill-gray-200 bg-transparent hover:bg-gray-200 hover:fill-gray-400 "
(if aside-open? "block " "hidden "))
:on-click #(refx/dispatch-sync [:app.dashboard/toggle-menu])})))))
children)))

(defnc aside
[{:keys [id class type theme
aria-label position]
aria-label position
children]
Comment on lines +27 to +28
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Ensure proper handling of children in the aside component

The aside component now accepts children as a prop. If children can be nil, ensure that the component gracefully handles this case without causing runtime errors.

:or {id ""
class ""
theme :mockingbird
Expand Down Expand Up @@ -92,3 +76,7 @@
#_(when aside-open?
(d/span {:class "ml-3"}
"Logout"))))))))


;; TODO aside specific components
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Address the TODO: Add aside-specific components

The TODO comment suggests adding specific components for the aside. Would you like assistance in developing these components, or should we open a GitHub issue to track this task?

(defnc aside-componet [])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Typo in function name aside-componet

The function name aside-componet appears to be misspelled. It should likely be aside-component.

Apply this diff to correct the typo:

-defnc aside-componet []
+defnc aside-component []
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
(defnc aside-componet [])
(defnc aside-component [])

2 changes: 1 addition & 1 deletion src/mockingbird/components/icon.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
;; TODO

(def styles
{})
{:mockingbird {}})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

LGTM! Consider adding a clarifying comment and addressing the TODO.

The change to the styles variable is approved as it provides a structure for potential theme-specific styling.

  1. As suggested in a previous review, consider adding a comment to clarify the purpose of the styles variable:
;; Styles map for theme-specific customization
(def styles
  {:mockingbird {}})
  1. There's a TODO comment above this definition. Please address it or provide context on what needs to be done.


(defnc icon
[{:keys [class theme label href
Expand Down
43 changes: 36 additions & 7 deletions src/mockingbird/components/image.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
[mockingbird.lib :refer-macros [defnc]]
[helix.dom :as d]))

(def pfp-styles {:mockingbird ""})
(def pfp-styles
{:default "w-8 h-8 rounded-none opacity-100"
:rounded "w-8 h-8 rounded-full opacity-100"
:loading "w-8 h-8 rounded-full opacity-30 animate-pulse"})

(defnc pfp
[{:keys [class theme image
Expand All @@ -22,12 +25,38 @@
padding :none}}]
(d/div
(d/img {:class (str (get pfp-styles theme) " "
(get-props {:size size
:roundness roundness
:shadow shadow
:margin margin
:padding padding
:class class}))
(get-props
{:size size
:roundness roundness
:shadow shadow
:margin margin
:padding padding
:class class}))
:src image
:alt alt})
children))

(defnc img
[{:keys [class theme image
alt size roundness
shadow margin padding
children]
:or {theme :mockingbird
image "/images/logo.png"
alt "test"
size :md
roundness :none
shadow :none
margin :none
padding :none}}]
(d/div
(d/img {:class (str (get-props
{:size size
:roundness roundness
:shadow shadow
:margin margin
:padding padding
:class class}))
:src image
:alt alt})
children))
20 changes: 10 additions & 10 deletions src/mockingbird/components/popup.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@
[helix.hooks :as hooks]
[refx.alpha :as refx]))

(def error-styles
{:card "rounded border-l-4 border-red-500 bg-red-50 p-4"
:tittle "block font-medium text-red-700"
:desc "mt-2 text-sm text-red-700"})

(def toast-data-styles
{:info {:class "bg-green-50 fill-green-700 text-green-700 border-green-700"}
:error {:class "bg-red-50 fill-red-700 text-red-700 border-red-700"}})

;; notification
(refx/reg-sub
:app/notifications
Expand All @@ -28,11 +37,6 @@
(fn [notification]
(refx/dispatch [:app/enqueue-notification
notification])))
;; alerts
(def error-styles
{:card "rounded border-l-4 border-red-500 bg-red-50 p-4"
:tittle "block font-medium text-red-700"
:desc "mt-2 text-sm text-red-700"})

(defnc error
[{:keys [id error description]}]
Expand All @@ -48,10 +52,6 @@
{:class desc}
(str description))))))

(def toast-data
{:info {:class "bg-green-50 fill-green-700 text-green-700 border-green-700"}
:error {:class "bg-red-50 fill-red-700 text-red-700 border-red-700"}})

(defnc toast [{[id {:keys [type content icon]}] :children}]
(hooks/use-effect
:once
Expand All @@ -61,7 +61,7 @@

(d/div
{:class (str "w-fit px-5 py-4 bg-blue-600 rounded-lg border-2 "
(get-in toast-data [type :class]))}
(get-in toast-data-styles [type :class]))}
(d/div
{:class "flex flex-row items-center align-center space-between"}
(d/div
Expand Down
19 changes: 0 additions & 19 deletions src/mockingbird/components/profile.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,6 @@
[promesa.core :as p]
[refx.alpha :as refx]))

(def gravatar-base-url "https://gravatar.com/avatar/")
(def auth0-cdn-base-url "https://cdn.auth0.com/avatars/")

(def pfp-styles
{:default "w-8 h-8 rounded-none opacity-100"
:rounded "w-8 h-8 rounded-full opacity-100"
:loading "w-8 h-8 rounded-full opacity-30 animate-pulse"})

(defn get-simple-avatar-url [username]
(let [uq-names (-> username
(str/split #" "))
initials (->> uq-names
(take 2)
(map #(take 1 %))
flatten
(str/join "")
str/lower-case)]
(str auth0-cdn-base-url initials ".png")))

(defn get-image-style
[{:keys [children image-style]}]
(let [image-style (keyword image-style)]
Expand Down
2 changes: 1 addition & 1 deletion src/mockingbird/helpers/props.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,5 @@
:md "m-4 "
:lg "m-8 "
nil)]
(str actual-size actual-roundness cast-shadow
(str actual-size actual-roundness cast-shadow
actual-padding actual-margin class)))
8 changes: 4 additions & 4 deletions test/unit/components/props_test.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@
(testing "All defaults (empty map)"
(is (= (get-props {})
"w-16 h-16 ")))

(testing "Partial defaults"
(is (= (get-props {:size :sm})
"w-8 h-8 "))
(is (= (get-props {:roundness :full
(is (= (get-props {:roundness :full
:shadow :lg})
"w-16 h-16 rounded-full shadow-lg ")))

(testing "Nil values"
(is (= (get-props {:size nil
(is (= (get-props {:size nil
:roundness nil})
"w-16 h-16 ")))))
Loading