I am facing the problem of not being able to access the main theme object from my styled components. Here is example, in my src/index.js I have theme object as bellow:
const marsTheme = {
name: "@frontity/mars-theme",
roots: {
/**
* In Frontity, any package can add React components to the site.
* We use roots for that, scoped to the `theme` namespace.
*/
theme: Theme,
},
state: {
/**
* State is where the packages store their default settings and other
* relevant state. It is scoped to the `theme` namespace.
*/
theme: {
colors: {
primary: "pink",
secondary: "orange",
},
...
Now, when I try to these theme.colors for example in my footer.js file like this:
const FooterContainer = styled.div`
color: ${(props) => {
console.log({ props }); // prints out { children: { some data.. }, theme: {} }
return "red";
}}
As you can see, the props here doesn’t provide theme object.
I tried adding some kind of theme provider with both styled-components and @emotion/react inside of my components/index.js (Theme component) like this:
<ThemeProvider theme={{ someField: "ciao" }}>
....
<Footer />
</ThemeProvider>
The result of the output is the same.
How can I link my theme properties to all of my components / styled-components?