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

docs(tools): Add link to a handy tool #67

Merged
merged 1 commit into from May 4, 2016

Conversation

kentcdodds
Copy link
Contributor

No description provided.

@xymostech
Copy link
Contributor

Looks great for a first pass! It looks like your CSS formatter doesn't do such a great job, I came up with something a little fancier, which you can see here: https://output.jsbin.com/wubiku

function formatCss(css) {
    while(/[{}](?!\s|$)/.test(css)) { //noprotect
        // indent '{'s
        css = css.replace(/(^|\n)( *)([^{}]+){(?!\n|$)/, "$1$2$3 {\n$2  ");
        // indent '}'s
        css = css.replace(/(^|\n)  ( *)([^{}]+)}(?!\n|$)/, "$1  $2$3\n$2}\n$2");
        // indent '}'s after a '}'
        css = css.replace(/(^|\n)  ( *)}(?!\n|$)/, "$1$2}\n");
    }
    return css;
}

I'd also like to have an interface where people can play around with mixing things into the css() function. Not sure what you think a UI would look like for that.

@kentcdodds
Copy link
Contributor Author

Fantastic! Yeah, I was looking for a better solution 😅 This is great!

I've updated the original jsbin, so we should be good to merge this, then we can think about enhancing it or adding a better tool in the future :-)

@kentcdodds
Copy link
Contributor Author

ping :-)

@kentcdodds
Copy link
Contributor Author

The tool has been updated to update the URL as the user types their styles so we can share output :-)

For example 😄

@xymostech
Copy link
Contributor

Cool! I was looking into the CSS formatting, and found that the thing I came up with still has a bunch of bugs. :P Any luck finding a real tool for doing CSS indentation? If not I might just make something quick that's a bit more complicated than some regexes.

@kentcdodds
Copy link
Contributor Author

For sure! Don't let that stop us from merging this though ;-)

Eventually it'd probably be best to put this in a real deployed tool on a for realz website for Aphrodite. We could have code highlighting and such with Code Mirror (which may actually be our best solution for formatting the CSS).

But let's iterate :-)

@xymostech
Copy link
Contributor

Fair enough!

@xymostech xymostech merged commit 3ba5a3e into Khan:master May 4, 2016
@ka-role
Copy link

ka-role commented May 4, 2016

https://www.npmjs.com/package/cssbeautify ?

On Wed, May 4, 2016 at 11:16 AM, Emily Eisenberg notifications@github.com
wrote:

Merged #67 #67.


You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub
#67 (comment)

@kentcdodds kentcdodds deleted the pr/add-output-tool-link branch May 4, 2016 19:18
@kentcdodds
Copy link
Contributor Author

@ka-role, thanks for mentioning it. Unfortunately it looks like it's got some bugs: https://jsbin.com/balusi/2/edit?html,css,js,output

@sophiebits
Copy link

sophiebits commented May 5, 2016

@ka-role is a role account for the KA organization. >.> How does it speak!

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

Successfully merging this pull request may close these issues.

None yet

4 participants