Skip to content
This repository has been archived by the owner on Oct 17, 2022. It is now read-only.

<pre> tag should have white-space: pre #14

Closed
nfriedly opened this issue Oct 4, 2016 · 6 comments
Closed

<pre> tag should have white-space: pre #14

nfriedly opened this issue Oct 4, 2016 · 6 comments

Comments

@nfriedly
Copy link
Contributor

nfriedly commented Oct 4, 2016

See

white-space: pre-line; // 2
- it sets white-space: pre, but then overrides it (twice), setteling on white-space: pre-line, which makes my pretty-printed JSON blocks look ugly.

This gets overridden somewhere for pre[class*="language-"] (maybe in the prism css), but I don't see any reason why it shouldn't be the default for other things.

@nfriedly
Copy link
Contributor Author

nfriedly commented Oct 4, 2016

Oh, and apparently we set white space: normal on .base--pre somewhere in the CSS - I'm not sure where that comes from...

@jzhang300
Copy link
Contributor

I did that to prevent unwanted spacing when we wrap pre tags around code tags. .base--pre code has white-space: pre.

@germanattanasio
Copy link
Contributor

Nathan when using react I think if you replace the state of the Code component it should reload the new code without you having to change it.

@nfriedly
Copy link
Contributor Author

nfriedly commented Oct 5, 2016

Something funky is going on. Here's my code:

        return (
            <div className="tab-panels" role="tabpanel">
                <ul className="tab-panels--tab-list" role="tablist">
                    <li className="tab-panels--tab-list-item base--li" role="presentation">
                        <a className="tab-panels--tab base--a active" href="#display_output_doc"
                           aria-controls="display_output_doc" role="tab">Output document</a>
                    </li>
                    <a title="Download output file" href={`/api/convert?document_id=${this.props.id}&conversion_target=${formats[this.props.format]}&download=true`}
                       className="download--output-icon icon icon-download download--icon"></a>
                </ul>
                <div className="tab-panels--tab-content">
                    <div id="display_output_doc" className="tab-panels--tab-pane active" role="tab-panel">
                        <Code type={this.props.format}>{this.state.output}</Code>
                    </div>
                </div>
            </div>
        );

And this is what it renders as:

screen shot 2016-10-05 at 10 06 44 am

The only CSS I'm including on the page is our watson-ui-components.min.css.

If I disable the white-space: normal from .base--pre, then it looks correct:

screen shot 2016-10-05 at 10 07 09 am

Should that class maybe be on the <pre> tag rather than the <code> tag? - That comes from the react components: https://github.com/watson-developer-cloud/react-components/blob/master/src/components/Code.js#L30

@nfriedly
Copy link
Contributor Author

nfriedly commented Oct 5, 2016

Actually, I think I answered my own question. If I move the .base--preclass off of the <code> and onto the <pre> then things look correct:

screen shot 2016-10-05 at 10 12 50 am

I included the fix in watson-developer-cloud/react-components#5

@jzhang300
Copy link
Contributor

jzhang300 commented Oct 5, 2016

I think in the sample documentation, we should say that <PrismCode> needs to be wrapped with <pre class="base--pre"></pre>

Edit: nvm, ignore this message

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

No branches or pull requests

3 participants