All Downloads are FREE. Search and download functionalities are using the official Maven repository.

components.buttons.ChangeSize.ChangeSize.jsx Maven / Gradle / Ivy

There is a newer version: 7.28.3
Show newest version
import React, { useContext } from 'react'
import PropTypes from 'prop-types'
import { connect } from 'react-redux'
import { UncontrolledButtonDropdown, DropdownToggle, DropdownMenu, DropdownItem } from 'reactstrap'

import { makeWidgetSizeSelector } from '../../../ducks/widgets/selectors'
import { DataSourceContext } from '../../../core/widget/context'
import { SIZES } from '../constants'

/**
 * Дропдаун для выбора размера(size) виджета
 * @reactProps {string} entityKey - id виджета, размер которого меняется
 * @reactProps {number} size - текущий размер(приходит из редакса)
 * @example
 * 
 */
function ChangeSizeComponent({ size: currentSize, icon, label, nested = false }) {
    const { setSize } = useContext(DataSourceContext)

    const items = SIZES.map((size, i) => {
        const onClick = () => setSize(size)

        return (
            
                
                    {currentSize === size &&