Can I use vscode file-icons in a webview? - visual-studio-code

Is it possible to have access or use file icons inside a webview? The icons on the side of each file/folder in the explorer.
My project has a custom activity bar, where I would like to show icons for a file type, preferably using the current Icon Theme, is this possible?
I've seen that code icons can be used, injecting the css in the webview:
const codiconsUri = webview.asWebviewUri(
vscode.Uri.joinPath(extensionUri, 'node_modules', 'vscode-codicons', 'dist', 'codicon.css'),
);
Then used like this inside the webview's HTML:
<i class="codeicons codeicons-beaker"></i>
But I have not been able to find any reference about how to do this with file icons.

I have the same issue.
I notice that the error code is 401(Unauthorized) when loading the codicon.css.
But it works if I copy the codicon.css and codicon.ttf files to the other folder which is the same level as the node_modules.

Related

VSCode extension api – file type/extension icons using ThemeIcon

We are building an extension that visualizes some data for workspace files in our view using a class derived from TreeDataProvider. We wonder if there is a way to use file icons contributed by the current File Icons Theme for our custom tree items. Base icon class has a field icon: ThemeIcon which supports product icons. Wonder if something similar exists for referring to file-type icons?
Thanks
Seems like using resourceUri and ThemeIcon.File is the way to do it:
this.iconPath = ThemeIcon.File;
this.resourceUri = Uri.parse('_.js');

Custom Ionic icon from Internet

I'd like to use ionic icons dynamically like this:
<ion-icon src="https://eu.ui-avatars.com/api/?background=0D8ABC&color=fff"></ion-icon>
Any idea how to make this work? (if it's possible)
The ion-icon component only accepts valid .svg files for src='/path/to/file.svg' attribute. As stated from the Ionicon documentation.
Custom icons
To use a custom SVG, provide its url in the src attribute to request the external SVG file. The src attribute works the same as in that the url must be accessible from the webpage that's making a request for the image. Additionally, the external file can only be a valid svg and does not allow scripts or events within the svg element.
<ion-icon src="/path/to/external/file.svg"></ion-icon>
The image in your src attribute is a .png format instead of a .svg which the component is expecting. This will then cause the component not to render the icon. If you instead use .svg it will turn out the way you expect.

Flutter | how to add custom Icons in Mapbox's markers/symbol

I was wondering how one could use his own icons in a Flutter-Mapbox plugins' marker?
There's no default marker icon (no provided icon - no marker),
and there's not enough documentation on how to use a custom image.
adding a symbol (marker) is as follows:
mapController.addSymbol(
SymbolOptions(
geometry:LatLng(0.0, 0.0), // location is 0.0 on purpose for this example
iconImage: "pin"
)
);
whereas the IconImage, a String, is the field which should contain the data about the icon (obviously), but the given example repository doesn't clarify the needed parameters (url, path etc.).
Providing a path to the assets doesn't work (unlike other widgets). In the example, they provide the IconImage field the value airport-15, and when running the app, it actually works, but I can't seem to find the resources' location (it's not in #drawables or my assets folder, or any other place in the project)
You have to create a custom style on using MapBox Studio.
Create a new dataset if not already exist
Create tileset
Create new style & select customize basic template
Create new layer, give it a name for example my_sym and add newly created datasource
Then click on type & change it to symbol
Now click on my_sym two times. (first one will close the option menu & second one will open a new menu with symbol properties
Click on icon tab & select new icon. You can also upload your own svg icon.
Click on publish
Click on share it will show you the urls.
Copy the type of url & set styleString property.
For more info follow steps here
https://docs.mapbox.com/help/tutorials/add-points-pt-1/
API reference:
https://docs.mapbox.com/mapbox-gl-js/api/
As of release 0.0.5 it will be possible to load custom icon images for your markers. The idea is to add the icon image to your assets folder (for example: assets/symbols/custom-icon.png). If you specify this image as an asset in your pubspec.yaml and set the iconImage in the SymbolOptions to this path it will be loaded automatically.
Regarding the airport-15, this is an icon provided by the Android implementation of the plugin. It is part of the Maki Icons used in Mapbox. Because these icons are part of the Android implementation you will not find as a Flutter asset or an Android resource of the example app.

why does the main app scss file in ionic 4 not work?

I've been working on an ionic app, I've come to do some styling on it and I'm having issues with app.scss.
According to the ionic documents I should be able to use app.scss for app-wide styles such as the toolbar etc. but nothing happens when I try to style anything from this file, it's like it's not being included in the build?
The initial project was done by creating the app in CLI with the sidebar menu option as the template and all the scss files work fine in the individual components.
Any idea why the app.scss file isn't working? I've inspected elements I've tried to style and they are not being picked up at all.
An example:
ion-title {
background: red;
}
this doesn't work, the toolbar background doesn't change, but it does through chrome inspector.
I have tried this in global.scss too and still nothing, funny thing is if I apply a display:none to all elements it works:
* {
display: none;
}
it just doesn't seem to want to style individual elements like the "ion-title"
UPDATE:
There seems to be a bug in ionic 4, the styleUrls won't accept me adding ../app.scss , it throws an error, but I can include ../app.css so I'm just going to auto-compile the scss to css.
I can then include the app.css file in each component and it's working!
In Ionic 4, global styles are saved by default in src/app/global.scss
If this is an Angular project that you are converting from an Ionic 3 template, you must add a reference to your global scss file in your angular.json file in under projects/app/architect/build/styles, like below
"styles": [
{
"input": "src/theme/variables.scss"
},
{
"input": "src/global.scss"
}
],
This is a change from Ionic 3 where it used to be in src/app/app.scss. If you created a project in Ionic 3 or earlier, you must move your styles into a new global.scss for them to be applied throughout the whole app
There seems to be a bug in ionic 4, the styleUrls won't accept me adding ../app.scss , it throws an error, but I can include ../app.css so I'm just going to auto-compile the scss to css.
I can then include the app.css file in each component and it's working!
You must include the path of app.scss file in your app.component.ts like this
styleUrls: ['app.scss']
Then you will be able to use your scss file

Where do Images go in IONIC 2

I am just getting started with Ionic 2. I have created an img file in app inside it is a file logo.png. So I have created the following code:
css:
.getting-started {
.logo {
background-image: url(./img/logo.png);
}
}
html:
<ion-col offset-33 width-33 class="logo"><h1>Logo</h1></ion-col>
<h3>Welcome to your first Ionic app!</h3>
</ion-content>
I know the css is working, as if I toggle the background color, I get the expected results. However, I don't get any background image, just the Logo text specified. Where should I have put the image file?
EDIT: As of Ionic 2 RC 0, the correct place to put your images is in src/assets/img/ and the correct code to reference the image is <img src="assets/img/myImg.png">. Please see Ionic's change log for RC0 (specifically #28).
As of right now, using the official Drifty Co. Ionic 2 Conference App as a reference, images should be placed inside of the www/ directory.
In my current Ionic 2 app, an image is located at www/img/logo.png and it is referenced in app/pages/page_name/page_name.html as <img src='img/logo.png'> and it works like a charm.
Currently using:
ionic-angular v2.0.0-beta.6 (package.json)
ionic-native ^1.1.0 (package.json)
ionic-cli v 2.0.0-beta.25 (installed CLI)
Using Ionic 2 beta 6, I handled this with a simple gulp task. I dropped my images in app/assets/images (this path is completely arbitrary). Then, I added the following task to gulpfile.js:
gulp.task("assets", function() {
return gulp.src(["app/assets/images/*"])
.pipe(gulp.dest("www/build/images"));
});
You'll also need to update the watch and build tasks to include the new assets task in their calls to runSequence(). I don't believe the order of tasks in the sequence matters, in this case:
gulp.task("build", ["clean"], function(done) {
runSequence(
["sass", "html", "fonts", "assets", "scripts"],
function() {
buildBrowserify().on("end", done);
}
);
});
If you output your images to the same path as I did, then you would reference your images in CSS from ../images/image-name.png and in <img> tags from build/images/image-name.png. I have confirmed that these images are visible both from the browser and an Android device. I don't think it should be any different for iOS.
The assets folder is the correct folder to place any media.
The location of my image:
fyi: if you dont have the folder, just create it
src > assets > img > background.png
variables.scss
.backgroundImage {
background-image: url('../assets/img/background.png');
}
Then on the page I want to use it on:
home.html
<ion-content padding class="backgroundImage">
</ion-content>
You can also reference images the following way:
home.html
<ion-content padding class="backgroundImage">
<img src="./assets/img/background.png" width="50%" />
</ion-content>
www\lib\ionic inside ionic create one folder img
now your path
www\lib\ionic\img put your background image inside this img folder and in your
www\lib\ionic\css\ionic.css
inside ionic.css find .view-container class and past this line.
.view-container {
background: url("../img/main_bg.jpg") repeat scroll 0 0 / 100% 100%;
}
OK, so I found the answer on the IONIC forum. The images go in www/img, the paths to these is then:
url('../../img/appicon.png')
when referenced from css or html in a page folder which is in pages in app.
Hope this helps anyone in the future.
I was having same problem, I found a way, I don't know if is the best way, but it's work.
the images must go on a file sibling to build, inside folder www
www
build
img
Got the solution. Its using path relative to index.html and not template folder.
So we need use path without../
src="img/John_Williams.jpg"
This works both on browser and apk
I could not manage to make it work using a PNG file. It worked in the browser but when I build the app and deployed to a device it did not displayed.
Instead of fiddling with the Gulp file to understand what was going on, I figured out a simpler workaround :
Inline the image into your HTML (or CSS) using a Data URI.
There are many tools online such as this one that will convert your PNG to a Base64 data URI.
If your image is pool.jpg. Place it in /src/assets/img/pool.jpg
It needs to be in this directory (assets) as it is your source from where everything gets built.
Then stop your ionic serve command (Ctrl-C) or whatever you use.
Then delete EVERYTHING under www directory (it all gets rebuilt anyway).
Then restart your server by running 'ionic serve' again.
This will rebuild the directory with the images.
You can reference the image as background-image: url('../assets/img/pool.jpg');
in your code.
I am using ionic 3 and it's a shame it doesn't pick up changes in the assets directory. IONIC should look at this.
I 'm currently on ionic version 3.6 and I had to use this to work:
src="../../assets/img/myImage.jpg"
The path assets/img/myImage didn't work for me
I hope this helps
Hi Guys i found a method add images to ionic v2
Create a images folder in "www" directory (www/images/) and add your all images in this path.
Then give your image path like this
ex: for pages
src="images/logo.png"
in CSS
.ThemeColor{ background: url(/images/bg.png)};
That's it, works for me..
Thanks