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

components.actions.Dropdowns.ChangeSize.jsx Maven / Gradle / Ivy

The newest version!
import React, { useContext } from 'react'
import PropTypes from 'prop-types'
import { UncontrolledButtonDropdown, DropdownToggle, DropdownMenu, DropdownItem } from 'reactstrap'
import { connect } from 'react-redux'

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

const SIZES = [5, 10, 20, 50]

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

    const items = SIZES.map((size, i) => (
         setSize(size)}>
            
                {currentSize === size &&