Vuetify dark theme customizing does not work - vue.js

I'm using Vue with Vuetify 1.5.14 and I'm trying to customize my theme. I just follow the docs to do this. When I apply color="primary" to my v-card component, it correctly uses the custom primary base color. However when I apply the dark property to it, it still show the base color instead of the darken1 color. This is my vuetify.js file:
Vue.use(Vuetify, {
iconfont: 'md',
theme: {
primary: {
base: '#673ab7',
darken1: '#320b86',
lighten1: '#9a67ea'
},
secondary: {
base: '#00bcd4',
darken1: '#008ba3',
lighten1: '#62efff'
},
accent: '#ffeb3b',
error: '#f44336',
warning: '#ffc107',
info: '#009688',
success: '#8bc34a'
}
});
Anyone has an idea how to properly customize the light theme colors?

From v1.5.14 docs:
Custom theme variants
While Vuetify automatically generates lighten and darken variants for theme colors, you may want to control this yourself. Simply pass a theme object that contains the variants that you wish to modify. Anything not provided will still be generated for you.
// src/theme.js
import colors from 'vuetify/es5/util/colors'
export default {
primary: {
base: colors.purple.base, // modifies `primary`
darken1: colors.purple.darken2 // modifies `primary darken-1`
},
When you set colors predefined by vuetify then light and dark variants are automatically set for you.
Modifying these options in vuetify v1 just change your custom lightening or darkening of your color i.e. primary lighten-1.
So in dark theme (i.e. <v-app dark) you would use them like so:
:color="$vuetify.dark ? 'primary darken-1' : 'primary'"
$vuetify.dark is a property which determines if you are using dark theme.
If you need this per component (i.e. you want to pass dark property to a component), then you need to manually extend a component to support that feature.
Automatic toggle between custom dark and light theme colors will be supported in v2. (already works in beta)

Related

Headless UI component will not take style

I'm currently playing around with Headless UI and I can't seem to style any of the components.
This is the code in my tabs file
<template>
<TabGroup>
<TabList class="bg-blue-900/20 rounded-xl">
<Tab>Products Information</Tab>
<Tab>Find Offices Nearby</Tab>
<Tab>Requirements</Tab>
</TabList>
<TabPanels>
<TabPanel>Content 1</TabPanel>
<TabPanel>Content 2</TabPanel>
<TabPanel>Content 3</TabPanel>
</TabPanels>
</TabGroup>
</template>
<script>
import { TabGroup, TabList, Tab, TabPanels, TabPanel } from '#headlessui/vue'
export default {
components: {
TabGroup,
TabList,
Tab,
TabPanels,
TabPanel,
},
}
</script>
It's either of these problems
Tailwind CSS is not installed or configured properly so you cannot use Tailwind CSS classes like 'rounded-xl'.
'bg-blue-900/20' is not an inbuilt tailwind CSS class, so either customize color in tailwind or use inbuilt colours like 'bg-blue-400', 'bg-blue-500', etc
Tailwindcss v2.1 introduced JIT mode that generates styles on-demand.
You need to enable jit mode to use such classes like bg-blug-900/20.
You can see how to do that in official doc

How to customize core components in Spartacus?

Is it possible to customize core Spartacus components like cx-icon? I need to extend cx-icon to add functionality to support Material Icons, so whenever I use cx-icon in the app, Material Icons are rendered and not FontAwesome icons
PS - Material icons cannot be configured in cx-icon as it doesn't use CSS classes like FontAwesome, rather it uses text ligatures
I'm not sure, but you can try to figure it out with SVG sprite. You just need to download Material Icons in SVG sprite format (more details here https://google.github.io/material-design-icons/) and to configure IconModule with custom matIconConfig like this (more details here https://sap.github.io/spartacus-docs/icon-library/):
export const matIconConfig: IconConfig = {
icon: {
symbols: {
INFO: 'info', // Here you should add actual xlink to SVS symbol
},
resources: [
{
type: IconResourceType.SVG,
url: './assets/mat-icons.svg',
types: [ICON_TYPE.INFO],
},
],
},
};
And then merge it to global configuration by:
ConfigModule.withConfig(matIconConfig);
Of course, during debugging, maybe you will need to apply some additional styles, but I can't provide which exactly.

Is there any method to achieve true Dark Mode in React Native for iOS?

When toggling Dark Mode in iOS, we can see the app previews in the app switcher immediately change their appearances even though suspended in the background.
This post aims to find out if it's possible to achieve this in React Native (regardless of using bare React Native or Expo), and if not, is there anyway we can help make it possible?
Observe the animation:
Or click here if it's not displaying.
The native Settings app, even though suspended in background, changes it's appearance when Dark Mode is toggled
The Expo client app, also suspended in the background (the app switcher was opened from Home, not while Expo is in use) does not change its appearance when Dark Mode is toggled. It will only do so when I tap to go back into the app
I'm not sure if Expo client is built with React Native because the behavior described in "2." does not always happen. But I've tried creating my own RN app with react-native-appearance and the colors do not change when suspended (as portrayed in the animation)
At the moment, there is a hacky way to partially achieve this, but I don't think anybody could stand to ship their app with it.
<View style={{
backgroundColor: isDarkModeOn ? 'black' : 'white', // remove this
}} />
Don't specify backgroundColor at all and it will behave like a native app even when suspended and viewed from the app switcher, probably because it's using a native value by default… but:
that only applies to backgroundColor
and only if it's a <View/> (or something equivalent)
and is limited to black and white
We still need to rely on JavaScript as long as one of the conditions above are not met.
I would like to believe that there's a solution out there that I'm not aware of. But so far none of the dark mode tutorials I find mention about this concern.
This can definitely be done, with code like this:
import { DynamicColorIOS } from 'react-native';
export const C = {
normalText: DynamicColorIOS({ dark: '#999', light: '#222'}),
normalTextBold: DynamicColorIOS({ dark: '#ccc', light: '#000'}),
titleText: DynamicColorIOS({ dark: '#777', light: '#999'}),
headingText: DynamicColorIOS({ dark: '#999', light: '#666'}),
borderLine: DynamicColorIOS({ dark: '#888', light: '#888'}),
background: DynamicColorIOS({ dark: '#000', light: '#fff'}),
internalLink: DynamicColorIOS({ dark: '#1EAEDB', light: '#01a'}),
};
I have no idea how this impacts Android compatibility, but if you change all of your stylesheets to use these paired-up colors (C.background on the right-hand side of a style property), you get proper light mode and dark mode color changing and animating by the system, as you describe. You can even test this in the iOS simulator with Cmd+Shift+A to change the appearance, which will animate from light to dark mode and back if you press it a second time.

How to inherit svg's css properties using vue svg loader

I am using vue-svg-loader to use my svg files as a component in Vue project. When I am rendering those svgs I am losing default css properties that are inside of the svg file. I can add those css properties inside of my component where I am rendering svg files, but that kind of violates the idea of reusable components since each svg file has its own property. Is there a way to inherit their css?
'''
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px"
viewBox="0 0 612 792" style="enable-background:new 0 0 612 792;" xml:space="preserve">
<style type="text/css">
.st0{fill:#FFFFFF;}
.st1{fill:none;}
.st2{fill:#FFFFFF;stroke:#000000;stroke-width:2;stroke-miterlimit:10;stroke-dasharray:10;}
.st3{font-family:'ArialMT';}
.st4{font-size:32px;}
</style>
<font horiz-adv-x="2048">
'''
Likely what is happening is that all of your SVG files use the same class names (st0, st1, etc). They are overriding each other. You'll need to:
manually rename the classes in each file, so they use different names, or
That file looks like it came from Illustrator. Assuming they all did, then load the SVGs back into Illustrator, and re-export them. This time change which method AI uses to set the element styles. I don't have AI handy right now, but there will probably be three options (I don't recall exactly what they are called):
Internal CSS - what the file above is using
Style attributes - uses the style="..." attrinbute
Attributes - uses attributes like fill="#ff0000"
If you need to style the SVGs with CSS in your page, you'll probably want to use the last option. That's because style attributes have a higher priority than CSS, so you would need to use the CSS !important flag, which is not generally recommended.
I've found that the vue-svg-loader documentation is pretty thin, mainly because all its configuration is done via the svgo library. There are some clues in this FAQ, which shows you how to customise the svgo configuration in your webpack config.
So maybe you want something like this in your vue.config.js file:
module.exports = {
chainWebpack: (config) => {
const svgRule = config.module.rule('svg');
svgRule.uses.clear();
svgRule
.use('babel-loader')
.loader('babel-loader')
.end()
.use('vue-svg-loader')
.loader('vue-svg-loader')
.options({
svgo: {
plugins: [
addClassesToSVGElement: {
classNames: ["foo", "bar"],
}
],
},
});
},
};

React components not respecting legend position configuration

Is there any reason why my chart legends are always appearing on the right? My config looks like this:
legend: {
enabled: true,
position: 'bottom'
}
Setting enabled to false causes the legend to disappear as expected, but changing the position has no effect.
This is using #gooddata/react-components 5.2.0-alpha17
The config looks correct. Please share the code for the whole component and we will have a look at it. This is unlikely the problem, but please try to use a stable version instead of alpha. Current stable version is 5.1.0.
Please check you are importing your styles correctly
import '#gooddata/react-components/styles/css/main.css';
This snippet should work:
<PieChart
projectId={projectId}
measures={measures}
config={{
legend: {
enabled: true,
position: 'bottom'
}
}}
/>
You can find more information about chart legends in the official documentation