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

Doc - Theme - Theming with Create React App - Scaffold custom styles #3659

Closed
nisnardi opened this issue Jun 12, 2019 · 9 comments · Fixed by #3652
Closed

Doc - Theme - Theming with Create React App - Scaffold custom styles #3659

nisnardi opened this issue Jun 12, 2019 · 9 comments · Fixed by #3652
Labels

Comments

@nisnardi
Copy link

Bug Report

The Theme doc for theming with Create React App has a step where you copy some theme files but running the following command will copy all the files without the theme folder structure and in a flat way.
yarn cpy node_modules/semantic-ui-less/_site/**/* src/semantic-ui/site

Steps

Follow the tutorial and execute the script

Expected Result

It will copy all the theme files with the right theme folder structure

Actual Result

After the running the script you'll see a flat file structure without the theme folders

Version

Current site version

@welcome
Copy link

welcome bot commented Jun 12, 2019

👋 Thanks for opening your first issue here! If you're reporting a 🐞 bug, please make sure you've completed all the fields in the issue template so we can best help.

We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can.

@layershifter
Copy link
Member

@nisnardi thanks for feedback and catch, really appreciate 👍 Will be updated in #3652, https://github.com/Semantic-Org/Semantic-UI-React/pull/3652/files#diff-f4bd9704de5dc9d71d35da9d136fa1c0

@tresdev
Copy link

tresdev commented Jun 28, 2019

npx cpy-cli **/* ../../../src/semantic-ui/site --cwd node_modules/semantic-ui-less/_site --parents

This is not copying anything in my case. I just created a new app with latest create-react-app and followed the instruction.

So I tried copying ( node_modules/semantic-ui-less/_site => src/semantic-ui/site) and paste manually. but then:

./node_modules/semantic-ui-less/semantic.less (./node_modules/css-loader/dist/cjs.js??ref--6-oneOf-8-1!./node_modules/postcss-loader/src??postcss!./node_modules/less-loader/dist/cjs.js??ref--6-oneOf-8-3!./node_modules/semantic-ui-less/semantic.less)

@import (multiple) "theme.less";
^
Can't resolve './theme.less' in '/Users/<directories....>/semantic-test/src/semantic-ui'
      in /Users/<directories....>/semantic-test/src/semantic-ui/theme.config (line 95, column 0)

This error came up so I copied other files in node_modules/semantic-ui-less.
And this error occured:

Module not found: Can't resolve '../../src/semantic-ui/themes/themes/default/assets/fonts/brand-icons.eot' in '/Users/<directories.....>/semantic-test/node_modules/semantic-ui-less'

@layershifter
Copy link
Member

I am not fully understand what happened:

npx create-react-app fresh-suir
yarn add @craco/craco craco-less semantic-ui-less --dev
npx cpy-cli **/* ../../../src/semantic-ui/site --cwd node_modules/semantic-ui-less/_site --parents

image

Then I configured @craco and did yarn start and included import 'semantic-ui-less/semantic.less' and get that error:

image

But, when I did all steps from guide everything started to work:

image

@tresdev
Copy link

tresdev commented Jun 28, 2019

I have no idea why the copying is not working for me.
I'm using the latest npm on macOS.

But I found what was the problem with other parts.
I didn't remove the last line from the original theme.config file.


/*******************************
         Import Theme
*******************************/

@import (multiple) "theme.less";

Had to remove those lines. I thought I only had to remove the Folders part and replace it.
Now it's working.

@GitGitZarko
Copy link

I've also remove the last line, but is it should to me removed?
Is it work properly now?

@layershifter
Copy link
Member

@tresdev

I created a new CLI util to copy files and scuffolding faster, please check #3752. Now, to copy files you need to run only:

$ npx @semantic-ui-react/bootstrap

@tresdev @GitGitZarko yep, the original import of theme.less should be removed, you should only these files at the bottom in theme.config:

/*******************************
            Folders
*******************************/

@themesFolder : 'themes';
@siteFolder  : '../../src/semantic-ui/site';

@import (multiple) "~semantic-ui-less/theme.less";
@fontPath : '../../../themes/@{theme}/assets/fonts';

@geoffreym74
Copy link

I believe I followed all of the instructions, and everything runs without errors, but the theme styles are not applied. I can't figure out what I am missing.

package.json:

...
  "dependencies": {
    ...
    "react": "^16.10.2",
    "react-dom": "^16.10.2",
    "react-scripts": "^3.2.0",
    "semantic-ui-react": "^0.88.1",
  },
  ...
  "devDependencies": {
    "@craco/craco": "^5.5.0",
    "@semantic-ui-react/craco-less": "^1.1.0",
    "semantic-ui-less": "^2.4.1"
  }

theme.config:

...
@themesFolder : 'themes';
@siteFolder  : '../../src/semantic-ui/site';

@import (multiple) "~semantic-ui-less/theme.less";
@fontPath : '../../../themes/@{theme}/assets/fonts';

craco.config.js:

module.exports = {
    plugins: [{ plugin: require('@semantic-ui-react/craco-less')}],
};

index.js:

import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
import * as serviceWorker from './serviceWorker';
import 'semantic-ui-less/semantic.less';

ReactDOM.render(<App />, document.getElementById('root'));
serviceWorker.unregister();

@kimdongseob
Copy link

kimdongseob commented Nov 4, 2019

@geoffreym74

Did you solve problem?? I have same problem...

How to customize without using @craco?.

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

Successfully merging a pull request may close this issue.

6 participants