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

Custom fonts/static assets #254

Open
mxkxf opened this issue Jan 24, 2022 · 4 comments
Open

Custom fonts/static assets #254

mxkxf opened this issue Jan 24, 2022 · 4 comments

Comments

@mxkxf
Copy link

mxkxf commented Jan 24, 2022

Hey there,

Thanks for making Playroom.

I'd like to serve up some local fonts to use from within Playroom but can't find any docs on how to do this.

Is it possible?

@michaeltaranto
Copy link
Contributor

Hey 👋

I would recommend doing this with a custom FrameComponent.

Here is a basic example:

// FrameComponent.tsx

export default ({ children }) => {
  return (
    <>
      <link href="---web font url---" rel="stylesheet" />
      {children}
    </>
  );
}

And then provide the path of that file to your playroom config:

// playroom.config.js

module.exports = {
  // ...
  frameComponent: './FrameComponent.tsx'
}

@mxkxf
Copy link
Author

mxkxf commented Jan 25, 2022

@michaeltaranto Thanks for the reply! Is there any way to host the fonts from the playroom dev server without these being served from the public web?

@michaelwarren1106
Copy link

michaelwarren1106 commented Feb 2, 2022

I've been trying to use a custom frame component to remove the margin on the iframe element body tag, etc

I did exactly what you suggest above (copy and paste), and i've been getting:

image

my Frame.tsx is:

export default ({ children }) => {
  return (
    <>
      <link href="---web font url---" rel="stylesheet" />
      {children}
    </>
  );
}

@mxkxf
Copy link
Author

mxkxf commented Feb 10, 2022

@michaelwarren1106 You'll need to add a CSS loader to your webpack config:

// playroom.config.js

module.exports = {
  // ...
  webpackConfig: () => ({
    module: {
      rules: [
        {
          test: /\.css$/,
          exclude: /node_modules/,
          use: ['style-loader', 'css-loader'],
        },
      ],
    },
  },
  // ...
};

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

No branches or pull requests

4 participants