Comments (16)
Sort of. Basically the component styles are added after the page is processed (so that all components are collected from the page), while these styles are injected while the page is being generated. Since this behavior means you need to be a bit more specific with global CSS (which is generally not the recommended method anyways), I kept it around.
This means, in your case, being a bit more specific should do the trick, for example perhaps changing the style selector to iframe.utterances-frame
or .utterances iframe
.
If you really want to override the styles, you can add your style element directly to .codedoc/content/index.tsx
(first thing inside the <Page>
component).
from codedoc.
Yes, using iframe.utterances-frame
worked from that global location. I will make it more specific later.
One last thing.
How is line 153...
codedoc/src/components/page/style.ts
Lines 149 to 155 in cdb1b59
...consistent with
Integrated Dark Mode
Its 2020, and dark-mode should be considered a universal right! Codedoc supports dark-mode on all your docs.
A universal right for all HTML elements except iframe
? ;)
Is it because iframe
is not considered a "doc"?
from codedoc.
A universal right for all HTML elements except
iframe
? ;)Is it because
iframe
is not considered a "doc"?
:))))
iframe
also has that right, unfortunately it falls out of CODEDOC's jurisdiction though. many websites do not even support the OS preference, I believe a good portion of operating systems don't even have such a preference, and there is no standard method for communicating CODEDOC's user preference (which can be set despite lack of OS support) to iframe
s. as a result, changing iframe
's background based on dark mode often times results in content of the iframe
not being readable. that is also why the default background is white, in case a website has not set any background color but have assumed a white background (which is the default behavior).
from codedoc.
Yes, that works. I have never seen this before. Thanks for the help! :D
from codedoc.
Ah, someone reported the same issue against utterance
utterance/utterances#290
from codedoc.
Quoting utterance/utterances#290 (comment)
So simply adding a css rule to give the
<iframe>
element atransparent
background should solve it.
Yes, I figured out that much last night as well. If I add the CSS
iframe {
background: transparent
}
to the bottom of styles/codedoc-styles.css
, then the problem is fixed.
How do I have CODEDOC put this CSS into this generated file?
from codedoc.
styles/codedoc-styles.css
includes all styles for CODEDOC components, so you can simply add some styling for your component. Using component style is the recommended way as well since it ensures this style is only affecting this particular component and not all <iframe>
s on the page.
Besides that, you can also add global scripts and stylesheets.
from codedoc.
Is the problem line 153?
codedoc/src/components/page/style.ts
Lines 149 to 155 in cdb1b59
Can that be removed?
from codedoc.
That is a default styling to ensure that the typical <iframe>
fits in well with the rest of the content, while also preserving its own intended style.
from codedoc.
I plan to change to a more targeted solution, but first I just wanted to get something working.
I wanted to try the global approach first, but it is not as global as I expected.
stylesheets: [
<style>{`
iframe {
background: transparent
}
`}</style>
]
My global styling got added before the styling by CODEDOC, so the CODEDOC styling overrode my styling.
Is this the intended behavior?
from codedoc.
Thanks for all these thorough answers. I am learning a lot from you! :)
from codedoc.
I got a local solution working with this code in the index.tsx
files of my custom component.
return <div>
<style>
{`
iframe.utterances-frame {
background: transparent
}
`}
</style>
<script src='https://utteranc.es/client.js'
{...attributes}
async />
</div>
My attempts to move the style to a style.ts
file as shown in the custom component documentation all failed :(
from codedoc.
@bender2k14 that is not a local solution. You are basically adding a redundant style element per component instance, which is generally not a good idea.
Why your attempts for using component styles failed? Perhaps I could assist on that front.
from codedoc.
Thanks for offering to help :)
I will describe my most recent attempt, which is also available in this branch.
I am trying to follow the example in the Custom Component documentation. To avoid introducing problems, I only changed things if I thought it was necessary. So the name "card" is still used in some places.
This approach doesn't work. The background
of the iframe
in question is still white
.
Here is my style.ts
import { themedStyle } from '@connectv/jss-theme';
import { CodedocTheme } from '@codedoc/core';
export const CardStyle = themedStyle<CodedocTheme>(theme => ({
card: {
'iframe.utterances-frame': { background: 'transparent' },
}
}));
Here is my index.tsx
import { ThemedComponentThis } from '@connectv/jss-theme';
import { RendererLike } from '@connectv/html';
import { CodedocTheme } from '@codedoc/core';
import { CardStyle } from './style';
export interface UtterancesOptions {
theme: string;
}
export function Utterances(
this: ThemedComponentThis,
options: UtterancesOptions,
renderer: RendererLike<any, any>,
) {
const classes = this.theme.classes(CardStyle);
let theme = 'github-light';
if (options && options.theme && options.theme !== '') theme = options.theme;
const attributes = {
'repo': 'bender2k14/tyson-williams-blog',
'issue-term': 'pathname',
'label': '💬comments',
'theme': theme,
'crossorigin': 'anonymous'
}
return <div class={`${classes.card}`}>
<script src='https://utteranc.es/client.js'
{...attributes}
async />
</div>
}
from codedoc.
I suspect changing your style.ts
to this would work:
import { themedStyle } from '@connectv/jss-theme';
import { CodedocTheme } from '@codedoc/core';
export const CardStyle = themedStyle<CodedocTheme>(theme => ({
card: {
'& iframe.utterances-frame': { background: 'transparent' },
}
}));
According to JSS docs for nested selectors.
from codedoc.
Yes JSS takes a bit of getting used to, since it looks a lot like CSS but you need to constantly remind yourself that its actually just JS ;-)
from codedoc.
Related Issues (20)
- The build process on gh-actions omits terminal output colors HOT 2
- Theme assets broken when hosted on GitLab Pages HOT 7
- New release with ansi_up fix HOT 4
- Hooking codedoc's router to run code on page change HOT 7
- Search shortcut (CMD+F / ctrl+F) displays the modal n times
- Help with plugin development and publishing on NPM HOT 7
- enhance the underline code block feature to support more languages HOT 2
- support info underlines in codeblocks
- update set-value to a non-vulnerable version
- Support RTL HOT 1
- decreasing the width-size of TOC HOT 2
- Ability to copy multiple lines from codeblocks HOT 7
- Running Codedoc as a container in Raspberry Pi
- GitHub Pages deployment failure after succeeding HOT 3
- Local build not working: TypeError: merge is not a function HOT 4
- Integrated Search missing HOT 2
- Update marked to 4.0.10 to avoid CVE-2022-21680 HOT 1
- Build not working: Non-string value passed to `ts.resolveTypeReferenceDirective` HOT 1
- Pre-build plugin HOT 1
- github action failure HOT 5
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 codedoc.