Fork me on GitHub
#hyperfiddle
<
2023-12-21
>
Can10:12:33

Hello! I'm currently working with the history router and was wondering if there's a way to configure it to open links in a new tab, similar to the "_blank" attribute in traditional anchor tags. Is this functionality supported, and if so, could you provide a code snippet to help me better understand how to implement it?

Geoffrey Gaillard13:12:28

Should do the trick:

(history/link <target route>
  (dom/props {:target "_blank"})
  (dom/text "Click me"))

1
Can13:12:17

Thank you so much!

Can13:12:22

In the context of the history router, if I'm using the history/navigate! function with a route like

(history/navigate! history/!history [:app.poms-00-main/entity-info-page [company-name "company"]])
how would I open in a new page?

Geoffrey Gaillard13:12:23

An history instance is local to a tab. For now, if you want to open a new tab programmatically: • get the link from the route with: (history/encode (history/build-route !history <route>)) • pass it to https://developer.mozilla.org/en-US/docs/Web/API/Window/open

Can06:12:06

Usage example:

(.open js/window (history/encode (history/build-route !history [:app/targetkw [param1 param2]])) "_blank")
It's working.

Geoffrey Gaillard13:12:52

New easier, self-contained way to get started and experiment with Electric: https://github.com/hyperfiddle/electric-fiddle

6
vollcheck16:12:06

hi, I've ran through the instructions in README and spotted couple typos - https://github.com/hyperfiddle/electric-fiddle/compare/main...vollcheck:electric-fiddle:main

gratitude-thank-you 1
vollcheck16:12:56

otherwise great repo and happy to play around with it, I appreciate that every new iteration brings more "hygiene" to the table

🙂 2
Dustin Getz17:12:11

thanks @U03N5HN4K1N - So that you get credit for the contribution, can you create a PR and comment on the PR that you release this into the public domain? (We still have to select a license for this repo)

tobias14:12:43

Is this a replacement for https://github.com/hyperfiddle/electric-starter-app or does it serve a different purpose?

Dustin Getz14:12:24

Yes that is the intent though we haven't made a final decision about what to do about that repo

👍 1