UNPKG

@wordpress/block-editor

Version:
8 lines (7 loc) 2.12 kB
{ "version": 3, "sources": ["../../../src/components/global-styles/utils.js"], "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useViewportMatch } from '@wordpress/compose';\n\nexport function useToolsPanelDropdownMenuProps() {\n\tconst isMobile = useViewportMatch( 'medium', '<' );\n\treturn ! isMobile\n\t\t? {\n\t\t\t\tpopoverProps: {\n\t\t\t\t\tplacement: 'left-start',\n\t\t\t\t\t// For non-mobile, inner sidebar width (248px) - button width (24px) - border (1px) + padding (16px) + spacing (20px)\n\t\t\t\t\toffset: 259,\n\t\t\t\t},\n\t\t }\n\t\t: {};\n}\n\n/**\n * Function that scopes a selector with another one. This works a bit like\n * SCSS nesting except the `&` operator isn't supported.\n *\n * @example\n * ```js\n * const scope = '.a, .b .c';\n * const selector = '> .x, .y';\n * const merged = scopeSelector( scope, selector );\n * // merged is '.a > .x, .a .y, .b .c > .x, .b .c .y'\n * ```\n *\n * @param {string} scope Selector to scope to.\n * @param {string} selector Original selector.\n *\n * @return {string} Scoped selector.\n */\nexport function scopeSelector( scope, selector ) {\n\tif ( ! scope || ! selector ) {\n\t\treturn selector;\n\t}\n\n\tconst scopes = scope.split( ',' );\n\tconst selectors = selector.split( ',' );\n\n\tconst selectorsScoped = [];\n\tscopes.forEach( ( outer ) => {\n\t\tselectors.forEach( ( inner ) => {\n\t\t\tselectorsScoped.push( `${ outer.trim() } ${ inner.trim() }` );\n\t\t} );\n\t} );\n\n\treturn selectorsScoped.join( ', ' );\n}\n"], "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAiC;AAE1B,SAAS,iCAAiC;AAChD,QAAM,eAAW,iCAAkB,UAAU,GAAI;AACjD,SAAO,CAAE,WACN;AAAA,IACA,cAAc;AAAA,MACb,WAAW;AAAA;AAAA,MAEX,QAAQ;AAAA,IACT;AAAA,EACA,IACA,CAAC;AACL;AAmBO,SAAS,cAAe,OAAO,UAAW;AAChD,MAAK,CAAE,SAAS,CAAE,UAAW;AAC5B,WAAO;AAAA,EACR;AAEA,QAAM,SAAS,MAAM,MAAO,GAAI;AAChC,QAAM,YAAY,SAAS,MAAO,GAAI;AAEtC,QAAM,kBAAkB,CAAC;AACzB,SAAO,QAAS,CAAE,UAAW;AAC5B,cAAU,QAAS,CAAE,UAAW;AAC/B,sBAAgB,KAAM,GAAI,MAAM,KAAK,CAAE,IAAK,MAAM,KAAK,CAAE,EAAG;AAAA,IAC7D,CAAE;AAAA,EACH,CAAE;AAEF,SAAO,gBAAgB,KAAM,IAAK;AACnC;", "names": [] }