简体   繁体   English

如何自定义对话框的宽度?

[英]How to customize dialog width?

I'm writing dialog component in React JS . 我在React JS编写对话框组件。 I want to make it larger. 我想把它放大。 I thought, that it could be possible with using of grid. 我认为,使用网格有可能实现。 unfortunately it isn't so. 不幸的是,事实并非如此。 How I remember in bootstrap I passed lg-class, how this issue can be solved in office365 dialog ? 我还记得在我通过lg-class的引导程序中,如何在office365 dialog解决此问题? My component: 我的组件:

export default class CalendarDialog extends Component {

    static defaultProps = {
        allowTextInput: false,
        formatDate: (date) => {
            if (date) {
                return date.toDateString();
            }

            return '';
        },
        firstDayOfWeek: DayOfWeek.Sunday,
        isRequired: false,
        isMonthPickerVisible: true,
        strings: DEFAULT_STRINGS,
        borderless: false,
        pickerAriaLabel: 'Calender',
    };

    constructor(props) {
        super();

        let { formatDate, value } = props;

        this.state = {
            selectedDate: value || new Date(),
        };
    }

    _onSelectDate = (date) => {
        console.log('state', this.state);

        this.setState({
            selectedDate: date,
        });
    }

    _calendarDismissed = () => {
        this._dismissDatePickerPopup();
    }


    render(){

        let {
            show,
            onClose
        } = this.props;

        const {
            firstDayOfWeek,
            strings,
        } = this.props;

        return (
            <div className="ms-Grid">
                <div className="ms-Grid-row">
                    <div className="ms-Grid-col ms-sm6">
                        <Dialog
                            isOpen={ show }
                            type={ DialogType.normal }
                            onDismiss={ onClose }
                            title='Version'
                            subText=''
                            isBlocking={ false }
                            containerClassName='ms-dialogMainOverride'
                        >

                            <VersionList/>
                            <DialogFooter>
                                <DefaultButton onClick={ onClose } text='Hey' />
                                <PrimaryButton onClick={ onClose } text='Save' />
                                <DefaultButton onClick={ onClose } text='Close' />
                            </DialogFooter>
                        </Dialog>
                    </div>
                </div>
            </div>
        );
    }

}

It should be enough to add a CSS rule containing 添加一个包含以下内容的CSS规则就足够了

.ms-dialogMainOverride {
  max-width: 600px;
}

But keep in mind not to put too much information and/or choices into the dialog and that the containerClassName property is marked in documentation as deprecated. 但是请记住不要在对话框中放入太多信息和/或选择,并且不要在文档中将containerClassName属性标记为已弃用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM