Comments (3)
Yes, the above where you defined :fn-force-nl
yourself doesn't remove things. Handling sets in the options map is complicated, and so what I ended up doing was allowing anything you specify to add to the set, but it doesn't redefine the entire set. You have to use :remove
to get default things out of the set. Which may not be clear. Maybe this from the zprint reference might be a little clearer.
from zprint.
Good question. This is clearly a bug, though whether of code or documentation is a open question. It turns out that :noarg1-body
is in the set :fn-force-nl
, which causes it to never be formatted onto on line. Since ->
is the only "user" of :noarg1-body
, you could get what you want by simply removing :noarg1-body
from :fn-force-nl
, thus:
(czprint i272 {:parse-string? true :remove {:fn-force-nl #{:noarg1-body}}})
(defn pressable-hooks
[props]
(let [{background-color :bgColor,
border-radius :borderRadius,
border-color :borderColor,
border-width :borderWidth,
type :type,
disabled :disabled,
on-press :onPress,
on-long-press :onLongPress,
on-press-start :onPressStart,
accessibility-label :accessibilityLabel,
children :children,
:or {border-radius 0, type "primary"}}
(bean/bean props)
long-press-ref (react/create-ref)
state (animated/use-value (:undetermined gesture-handler/states))
active (animated/eq state (:began gesture-handler/states))
gesture-handler (animated/use-gesture {:state state})
animation (react/use-memo
(fn []
(animated/with-timing-transition
active
{:duration (animated/cond* active time-in time-out),
:easing (:ease-in animated/easings)}))
[])
{:keys [background foreground]}
(react/use-memo (fn []
(type->animation {:type (keyword type),
:animation animation}))
[type])
handle-press (fn [] (when on-press (on-press)))
long-gesture-handler
(react/callback
(fn [^js evt]
(let [gesture-state (-> evt .-nativeEvent .-state)]
(when (and on-press-start
(= gesture-state (:began gesture-handler/states)))
(on-press-start))
(when (and on-long-press
(= gesture-state (:active gesture-handler/states)))
(on-long-press)
(animated/set-value state
(:undetermined gesture-handler/states)))))
[on-long-press on-press-start])]
(animated/code!
(fn []
(when on-press
(animated/cond* (animated/eq state (:end gesture-handler/states))
[(animated/set state
(:undetermined gesture-handler/states))
(animated/call* [] handle-press)])))
[on-press])
(reagent/as-element
[gesture-handler/long-press-gesture-handler
{:enabled (boolean (and on-long-press (not disabled))),
:on-handler-state-change long-gesture-handler,
:min-duration-ms long-press-duration,
:max-dist 22,
:ref long-press-ref}
[animated/view
{:accessible true, :accessibility-label accessibility-label}
[gesture-handler/tap-gesture-handler
(merge
gesture-handler
{:shouldCancelWhenOutside true,
:wait-for long-press-ref,
:enabled (boolean (and (or on-press on-long-press on-press-start)
(not disabled)))})
[animated/view
[animated/view
{:style (merge absolute-fill
background
{:background-color background-color,
:border-radius border-radius,
:border-color border-color,
:border-width border-width})}]
(into [animated/view {:style foreground}]
(react/get-children children))]]]])))
I believe this will get you what you want. I'll fix the documentation of this function style to include the fact that it is included in :fn-force-nl
. Thanks!
Thanks for asking!
from zprint.
Thanks. It works now. I tried below before and it won't work. Seems the :remove
option has a higher priority.
:fn-force-nl #{:noarg1 :force-nl-body :force-nl :flow
:arg1-force-nl :arg1-force-nl-body :flow-body
:arg2-force-nl-body :arg2-force-nl}
from zprint.
Related Issues (20)
- Wired justify in bindings with map on the left HOT 14
- Indentation inside namespaced maps is wrong HOT 2
- `;!zprint {:format :off}` deletes the outer key from namespaced maps HOT 3
- Aliasing a function to another in :fn-map does not work on namespaced function calls HOT 3
- Empty maps are removed when using `;!zprint {:format :off}` HOT 2
- :map :key-order request: HOT 2
- Option for `:rod` to not add newline after arglist when whole defn can fit into single line HOT 15
- How to force blank lines between vector elements? HOT 20
- `;!zprint {:format :skip}` removes arglist when there's zero arg HOT 1
- 1.2.5 format changes: `dissoc` HOT 3
- Slowness when pairing smaller width with long strings HOT 4
- Search for .zprintrc in XDG_CONFIG_HOME HOT 1
- Request or help if exists already - `#js` reader syntax in cljs interop HOT 9
- how do I to check or write all files recurisvely in a folder? HOT 1
- Custom Syntax Formatting: Hiccup HOT 10
- "Smart" comment changes feedback HOT 15
- Parinfer compatability HOT 2
- Vertical alignment HOT 6
- Adding Better Clojure Formatting from Tonsky HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zprint.