Comments (2)
I think I figured out a workaround:
first, just use the image like any other normal react project, put the image in webview-ui/src/user.png
:
App.css
.user-avatar {
background-image: url(./user.png);
background-size: contain;
background-repeat: no-repeat;
background-position: center;
}
After that, the image should be able to display when run npm run start
directly inside the webview-ui project. However, it won't work in extension.
Then, override the css in extension html,
const userImage = getUri(webview, this.context.extensionUri, [
"webview-ui",
"build",
"assets",
"user.png",
]);
<style nonce="${nonce}">
.user-avatar {
background-image: url("${userImage}");
background-size: contain;
background-repeat: no-repeat;
background-position: center;
}
</style>
This would make sure that the image could be correctly displayed in extension.
from vscode-webview-ui-toolkit.
Accroding to GPT, another way it to get the image uri via message. However, this is unnecessary complex, and need to maintain a state to store the uri.
from vscode-webview-ui-toolkit.
Related Issues (20)
- A11y Testing for vscodeedu.com - Text Spacing doesn't adjust for VS Code UI Toolkit buttons
- A11y Testing for vscodeedu.com - VS Code UI Toolkit doesn't adapt to Windows High Contrast themes
- React button not showing icon HOT 13
- Method of programmatically applying focus to text field in react HOT 1
- Add spellcheck to vscode-textarea
- Update dependencies to latest stable versions
- The last option in the dropdown has an empty space at the bottom HOT 1
- Keyboard Event Listener not working with text-field component? HOT 2
- Support description panel for the dropdown options
- Feature Request: sash
- Makes sure only one option is highlighted in dropdown. HOT 1
- Does text-field support validation? HOT 1
- How to have PanelViews fill the Panels?
- Checkboxes squish when their parent container's width shrinks HOT 1
- How do you use icon buttons? The code examples don't work. HOT 2
- Why is provideVSCodeDesignSystem() necessary? HOT 2
- Mark React components as Pure for tree-shaking
- Registering components causes CSP style-src errors HOT 1
- The example use an old version of esbuilt which isn't compatible with the 0.20.0
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 vscode-webview-ui-toolkit.