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

Please include images in this project #442

Closed
xiaoxiangmoe opened this issue Jan 25, 2018 · 16 comments · Fixed by #2390
Closed

Please include images in this project #442

xiaoxiangmoe opened this issue Jan 25, 2018 · 16 comments · Fixed by #2390

Comments

@xiaoxiangmoe
Copy link

form-validation.scss include too many background-image with absolute path which works well in github

For example:

@broccolini @shawnbot

if I use web application bundler like Parcel.js, it will crash for no file exists in /images/spinners/ dir in my computer.

@broccolini
Copy link
Member

Thanks for letting us know about this issue @zhaojinxiang! We'll update this in our next release.

@shawnbot
Copy link
Contributor

One way that we could handle this is to have one or more variables where the URLs of certain images live, so that non-github — or even just uses outside of github.com, such as in the style guide — could change them as needed.

@github-actions
Copy link
Contributor

Hi! This issue has been marked as stale because it has been open with no activity for 180 days. You can comment on the issue or remove the stale label to keep it open. If you do nothing, this issue will be closed in 7 days.

@github-actions github-actions bot added the Stale Automatically marked as stale. label May 26, 2021
@github-actions github-actions bot closed this as completed Jun 2, 2021
@xiaoxiangmoe
Copy link
Author

xiaoxiangmoe commented Jun 3, 2021

@yaili Can we reopen this issue?

@yaili yaili reopened this Jun 3, 2021
@github-actions github-actions bot removed the Stale Automatically marked as stale. label Jun 3, 2021
@dumptyd
Copy link

dumptyd commented Jun 13, 2021

I'm running into a similar issue when I import S/CSS files from @primer/css and the webpack config is using css-loader>=4. Tracked it down to this: https://stackoverflow.com/a/63224177.

It would be good if it's resolved in @primer/css itself, but until its not, webpack can be configured this way to ignore these patterns:

resolve: {
  alias: {
    '/images/spinners': false,
    '/images/modules': false
  }
}

@ahmadnassri
Copy link

+1 on this, surprised this has been open since 2018!

@ChildishGiant
Copy link

We'll update this in our next release.

There have been 8 major releases since this and the issue is still prevalent 😬

@github-actions
Copy link
Contributor

Hi! This issue has been marked as stale because it has been open with no activity for 180 days. You can comment on the issue or remove the stale label to keep it open. If you do nothing, this issue will be closed in 7 days.

@github-actions github-actions bot added the Stale Automatically marked as stale. label May 17, 2022
@xiaoxiangmoe
Copy link
Author

👀

@github-actions github-actions bot removed the Stale Automatically marked as stale. label May 17, 2022
@amirmasoudabdol
Copy link
Contributor

Is there any updates on this?

@danielnc
Copy link

I am also having the same issue here

@deetter
Copy link

deetter commented Oct 15, 2022

GOOD DAY/EVENING

@heynan0
Copy link
Contributor

heynan0 commented Feb 21, 2023

I'm trying to integrate the sass version of @primer/css into my team's application Rails asset pipeline, but this one is proving to be a problem. Our config.assets.prefix is /assets while @primer/css has hard-coded /images

This might be useful information, esp. for those using sass-loader in webpack:

https://github.com/webpack-contrib/sass-loader/tree/75dcfde159fe5508861f36ca577f71630c0d623e#problems-with-url

What's the update on the issue?

@howdyray
Copy link

@heynan0 Can you give us some more context to your use-case? We generally advise teams towards using PVC components instead of CSS clases to compose experiences. Would that help address your use case?

@heynan0
Copy link
Contributor

heynan0 commented Feb 22, 2023

@howdyray, it's not about using class names. We already use Primer View Components. The problem is integrating the .scss version of @primer/css into one's own asset pipeline.

Right now our team's application has to hard-code a CDN dist css version as a <link> tag. Upgrading the version in package.json does not automatically upgrade it since we also have to go to that template and update the URL in the <link> tag (point: someone might forget we have to do that and we cannot leverage dependabot version updates without manual intervention). That approach has been there since the introduction of dart sass functions in @primer/css that are not available in the now-obsolete sassc implementation that we have been using. We had no way of upgrading sass until now. And we want to be able to @use/import like this:

// application.scss (Rails)
@import "@primer/css/index.scss";

The above does not work properly because of lines such as:

background-image: url('/images/spinners/octocat-spinner-16px.gif');

The above throws an error in the console. The path string passed to the url() function is hard-coded to start with /images/...

One's application might not have that exact path available.

In a default Rails application, the pipeline is served from /assets, not /images. The url would return 404. Therefore one would be forced to change the default asset prefix by setting config.assets.prefix to /images. Existing paths constructed with /assets would have to be changed else they would break. Also, not all assets are images necessarily; we could have icons and fonts, so the naming /images isn't truthful for one's own application assets prefix.

Another way would involve having to rewrite the path string prefixes to url(), something I could not figure out how to do.

As recommended in https://github.com/webpack-contrib/sass-loader/tree/75dcfde159fe5508861f36ca577f71630c0d623e#problems-with-url, the library could use a variable:

Library authors usually provide a variable to modify the asset path. bootstrap-sass for example has an $icon-font-path.

@simurai
Copy link
Contributor

simurai commented Feb 22, 2023

@heynan0 Thanks for the details. 🙇

We chatted about this today in our weekly meeting. Using a variable might be an option, but we think it's ok to just move these url('/images/... styles to dotocom so that Primer CSS doesn't reference any image paths. Reasoning:

  • .is-autocheck-... classes get added/removed by the autocheck behavior that lives on dotcom.
  • We already have other autocheck styles here that replaces the images with SVGs.
  • These styles are kinda deprecated because we tried to replace all the gifs with the Spinner component in the past but just haven't finished the migration in all places.
  • Same for status-indicator

I can make a PR with the removal.

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

Successfully merging a pull request may close this issue.

14 participants