Open pMonfared opened 7 years ago
same problem
Can you please try logging require('react-persian-datepicker\lib\styles\basic.css')
?
console.log(require('react-persian-datepicker\lib\styles\basic.css'));
there is an alternative with working css: https://www.npmjs.com/package/react-persian-calendar
@mohebifar
Hi .
i use "webpack": "^2.7.0"
and i do this :
import basic from 'react-persian-datepicker/lib/styles/basic.css';
then inside the constructor :
constructor(props) {
super(props);
console.log(basic);
}
And finally the result of the console is empty Object : {}
And in my webpack.config is like this :
{
test: /\.css$/,
include: /node_modules/,
use: [
'style-loader',
'css-loader'
]
},
{
test: /\.s[ac]ss$/,
exclude: /node_modules/,
use: ['style-loader',
{
loader: 'css-loader',
options: {sourceMap: true}
},
'sass-loader'
]
}
thanks for your help
@htondkar @pMonfared @mayyamak You must set the modules
option of css-loader
to true
:
{ loader: 'css-loader', options: {modules: true, sourceMap: true} }
@mohebifar thanks for your help . I set up the ( options ) and it works right now.
But there is another problem . When click on day, the (div.tether-element)class does not close . What is your idea for this problem.solution ?
Use this css file. @thg303 gathered it from the one in the repository. don't forget to fix the extension to ".css" evan-calender-style.css.txt
After adding styles, you need to present the styles to the DatePicker :
const styles= { calendarContainer: 'calendarContainer', dayPickerContainer: 'dayPickerContainer', monthsList: 'monthsList', daysOfWeek: 'daysOfWeek', dayWrapper: 'dayWrapper', selected: 'selected', heading: 'heading' }
then:
<DatePicker calendarStyles={styles}/>
@mohebifar tnx this was a great help :)
@mohebifar is there anyway to include the styles without setting 'modules' to true? because it messes up some other styles on my app :(
const styles = { calendarContainer: "calendarContainer", dayPickerContainer: "dayPickerContainer", monthsList: "monthsList", daysOfWeek: "daysOfWeek", dayWrapper: "dayWrapper", selected: "selected", heading: "heading", next: "next", prev: "prev", title: "title", }
<Calendar styles={ styles } />
<DatePicker calendarStyles={ styles } />
@FareheSoheil What @asiye suggested is exactly what you would have to do if you don't want to use css-modules
.
@asiye @mohebifar I did what you told , but still styles are not applied , although there are no undefined classes. Don't know what is happening :(
i use webpack 3.4.1 : (configuration file)
when i run cmd : dev-watch webpack getback this error :
i changed webpack config loaders ( css ) to this codes :
and webpack complie without any error but don't show style for datepicker like this photo: