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

Feature: Generate map files from the css renderer #216

Open
ddssff opened this issue Apr 28, 2021 · 15 comments
Open

Feature: Generate map files from the css renderer #216

ddssff opened this issue Apr 28, 2021 · 15 comments

Comments

@ddssff
Copy link
Contributor

ddssff commented Apr 28, 2021

It looks to me like it would be possible to use the sourcemap package (https://hackage.haskell.org/package/sourcemap) and the mechanisms in GHC.Stack to generate a map file that would point you to lines in the Clay Haskell source from the browser's developer console. I hope to take a stab at this in the near future, but welcome any input or assistance.

@bsima
Copy link
Contributor

bsima commented Apr 28, 2021 via email

@turion
Copy link
Collaborator

turion commented Apr 29, 2021

That would be very useful! PRs welcome.

@ddssff
Copy link
Contributor Author

ddssff commented Apr 30, 2021

I've pushed the first step to https://github.com/seereason/clay, a patch that adds a state monad to the Css type to hold the SourceMappings. It doesn't yet add any mappings.

@ddssff
Copy link
Contributor Author

ddssff commented Apr 30, 2021

Can anyone explain why travis-ci is failing? https://github.com/seereason/clay/runs/2472160906

@turion
Copy link
Collaborator

turion commented Apr 30, 2021

Can anyone explain why travis-ci is failing? https://github.com/seereason/clay/runs/2472160906

From a superficial look it seems like that the nixpkgs in scope on CI is newer, and doesn't support the old GHC versions anymore.

@turion
Copy link
Collaborator

turion commented Apr 30, 2021

You could cherry pick the commit ci: update ghc versions to match pinned nixpkgs from https://github.com/sebastiaanvisser/clay/pull/215/commits, or wait a bit until I've reviewed and merged that, and rebase onto the newest master.

@ddssff
Copy link
Contributor Author

ddssff commented Apr 30, 2021

I'm stuck on ghc-8.6.5 and ghcjs-8.6.0.1 for now. Just FYI. But of course travis can run what it likes.

@ddssff
Copy link
Contributor Author

ddssff commented Apr 30, 2021

Next step: need to track the position in the generated file (the Builders.) Each mapping is a name and position in the original file (which will come from the CallStack,) and a position in the generated file. Sadly I don't know about Builders.

@turion
Copy link
Collaborator

turion commented May 1, 2021

You could open a pull request, and I'll advise. Maybe @bsima can help as well.

@ddssff
Copy link
Contributor Author

ddssff commented Jun 12, 2021

My biggest challenge right now is how to reliably collect all the Css values in my program so they can be rendered and turned into something that can be served to the browser.

@turion
Copy link
Collaborator

turion commented Jun 15, 2021

Do you have some example to illustrate what you mean?

@ddssff
Copy link
Contributor Author

ddssff commented Jun 16, 2021

Hmm, let me look over my code.

@ddssff
Copy link
Contributor Author

ddssff commented Jun 16, 2021

My question is, what is the best way to ensure that all the Css values for all the subsystems of my app (search, drag, tables, layout, many others) all get rendered, written into files, and installed so the server can see them and serve them to the client. Maintaining a list of them in the server main is error prone.

To make sure the client and server agree on class names, I use a class CssClass(cssClass) to manage the names:

data DismissCss = Dismissable | AppDismiss deriving (Eq, Ord, Show)
instance CssClass DismissCss where cssClass = show

Now scattered throughout the code we have Css values and client haskell code that use these class names:

dismissCss :: Css
dismissCss = do
    star # byClass' Dismissable ? do
      star # byClass' AppDismiss ? do
         position absolute
         color grey
         background transparent
         top (em 0.2)
         right (em 0.2)

and in the client

dismiss :: (Renderer' h m, HasCallStack) => Lens' (Sh h) Bool -> m ()
dismiss lns =
  buttonA (\_ -> do
              lns .= True
              tell [RenderFull]) faDismiss `with` [classes_ [cssClass AppDismiss]]

So how do we ensure that all the Css values in the program get to a place where the server can see them and serve them to the running clients? I've gone through a couple of solutions, but I wondered if I'm missing something obvious.

@ddssff
Copy link
Contributor Author

ddssff commented Jun 18, 2021

One possibility is to have a class CssStyle(cssStyle) and collect all instances using the template haskell reifyInstances function. But then you have to make sure you have imported all modules with instance when you call it.

Copy link

This issue has not seen any activity in a long time. If no further activity occurs, it will be closed after ten weeks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants