JavaScript How to import svg into next.js component? import next in python,import css in next js,import

Another approach would be to make a component for you svg. I like this approach because I can easily pass in props for width, height color etc if required on the svg.

eg

//GoogleLogo.js
import React from "react";
export default function GoogleLogo() {
  return (
    <svg className="svgIcon-use" width="25" height="37" viewBox="0 0 25 25">
      <g fill="none" fillRule="evenodd">
        <path
          d="M20.66 12.693c0-.603-.054-1.182-.155-1.738H12.5v3.287h4.575a3.91 3.91 0 0 1-1.697 2.566v2.133h2.747c1.608-1.48 2.535-3.65 2.535-6.24z"
          fill="#4285F4"
        />
        <path
          d="M12.5 21c2.295 0 4.22-.76 5.625-2.06l-2.747-2.132c-.76.51-1.734.81-2.878.81-2.214 0-4.088-1.494-4.756-3.503h-2.84v2.202A8.498 8.498 0 0 0 12.5 21z"
          fill="#34A853"
        />
        <path
          d="M7.744 14.115c-.17-.51-.267-1.055-.267-1.615s.097-1.105.267-1.615V8.683h-2.84A8.488 8.488 0 0 0 4 12.5c0 1.372.328 2.67.904 3.817l2.84-2.202z"
          fill="#FBBC05"
        />
        <path
          d="M12.5 7.38c1.248 0 2.368.43 3.25 1.272l2.437-2.438C16.715 4.842 14.79 4 12.5 4a8.497 8.497 0 0 0-7.596 4.683l2.84 2.202c.668-2.01 2.542-3.504 4.756-3.504z"
          fill="#EA4335"
        />
      </g>
    </svg>
  );
}

and in your file from above.

  import GoogleLogo from "./GoogleLogo";

  class Login extends React.Component {
    render() {
      return (
        <LoginLayout title="Login Page">
          <div>
            <Link target='_blank' href="/auth/google">
              <a className="button">
                <div>
                  <span className="svgIcon t-popup-svg">
                    <GoogleLogo />
                  </span>

                </div>
              </a>
            </Link>
          </div>
        </LoginLayout>
      );
    }
  }
Answer:1

I've recently added this myself. I followed the example on the Next.js repo.

https://github.com/zeit/next.js/tree/master/examples/svg-components

There's a couple of steps -

1) You need to install the following dependency :

  • babel-plugin-inline-react-svg

2) Inside your .babelrc you need to add the plugin babel-plugin-inline-react-svg

  "plugins": [
    "inline-react-svg",
  ]

You should then be able to import your SVG's into your components. Here's a gist of something similar I used it for.

https://gist.github.com/iamchristough/493c60112770058566d559e6860dc4c9

Note - you need to declare it as its own component <GoogleLogo /> if you just did {GoogleLogo} it will error. Also there is an issue with how babel transforms the SVG so any changes inside the SVG file won't appear. You need to rename the file in order for the bundler to see a change.

Hope this helps.

Answer:2

I have a video gallery with thumbnails. when I click on a thumbnail a video shows up. how can I stop/reset video that's playing when I click on another thumbnail? here is the code I have function ...

I have a video gallery with thumbnails. when I click on a thumbnail a video shows up. how can I stop/reset video that's playing when I click on another thumbnail? here is the code I have function ...

  1. stop video when modal closes
  2. videos stop on facebook
  3. stop video on spotify
  4. stop video on zoom
  5. stop video on instagram
  6. stop video on youtube
  7. video on stop bullying
  8. stop video on iframe
  9. stop videos on facebook from autoplaying
  10. stop videos on daily mail
  11. stop videos on facebook playing automatically
  12. stop video playing when modal is closed

I am trying to print array element to console using for each loop in javascript. But I am printing something which I am not able to figure out what! let arr=["1,2,3","iosajah","undefined"]; for(...

I am trying to print array element to console using for each loop in javascript. But I am printing something which I am not able to figure out what! let arr=["1,2,3","iosajah","undefined"]; for(...

  1. print array elements in java
  2. print array elements in c
  3. print array elements bash
  4. print array elements python
  5. print array elements javascript
  6. print array elements php
  7. print array elements in reverse order java
  8. print array elements in shell script
  9. print array elements perl
  10. print array elements using recursion java
  11. print array elements in reverse order c++
  12. print array elements in new line javascript
  13. print array elements in reverse order javascript
  14. print array elements in ascending order
  15. print array elements using recursion in c
  16. print array elements in one line java
  17. print array elements using pointers
  18. print array elements in scala
  19. print array elements in matlab
  20. print array elements in java 8

Assuming I have this list const foo = [ { id: 1, bar: [ {id: 1, a: null}, {id: 2, a: 224}, {id: 3, a: 345}, ] }, { id: 2, bar: [ {id: 4, a: 763}, {id: 5, a: null}, {id: 3, a: ...

Assuming I have this list const foo = [ { id: 1, bar: [ {id: 1, a: null}, {id: 2, a: 224}, {id: 3, a: 345}, ] }, { id: 2, bar: [ {id: 4, a: 763}, {id: 5, a: null}, {id: 3, a: ...

  1. list filter list
  2. list filter list java
  3. filter list by list python
  4. filter list of list java 8
  5. python filter list list comprehension
  6. filter list in list c#
  7. filter list inside list in java 8
  8. filter list with list excel
  9. filter list in list c# linq
  10. filter list in list linq
  11. filter list in list javascript
  12. filter list with list js
  13. filter list of list in r
  14. filter list with another list c#
  15. filter list by another list python
  16. filter list with another list java
  17. filter list by another list excel
  18. filter list from another list in java 8
  19. filter list with boolean list python
  20. filter list vs distribute list ospf

I am making a dark mode for a site using a button toggle. To keep the dark mode saved when changing pages, I am using cookies. When pressing the toggle again, the dark mode is disabled but is not ...

I am making a dark mode for a site using a button toggle. To keep the dark mode saved when changing pages, I am using cookies. When pressing the toggle again, the dark mode is disabled but is not ...

  1. isn't
  2. https://www.instagram.com/
  3. isnetworld
  4. instagram
  5. isn't she lovely
  6. isnt it romantic
  7. isna
  8. isn't it ironic
  9. isner
  10. isnull sql
  11. isn network
  12. isnac 2020
  13. isnt she lovely chords
  14. isns
  15. isnan
  16. isn't it
  17. isnull
  18. isn't it romantic cast
  19. isna excel
  20. disney plus