{"id":24079910,"url":"https://github.com/hypersoftllc/qc-react-block","last_synced_at":"2025-02-26T23:48:14.855Z","repository":{"id":65481584,"uuid":"109623301","full_name":"hypersoftllc/qc-react-block","owner":"hypersoftllc","description":"A React component that renders a div with the semantics of representing a block structure or region.","archived":false,"fork":false,"pushed_at":"2018-04-04T02:36:53.000Z","size":329,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"develop","last_synced_at":"2025-02-10T06:35:03.283Z","etag":null,"topics":["react-component","semantic"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hypersoftllc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-11-05T22:47:12.000Z","updated_at":"2018-04-04T02:35:37.000Z","dependencies_parsed_at":"2023-01-25T16:30:56.755Z","dependency_job_id":null,"html_url":"https://github.com/hypersoftllc/qc-react-block","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hypersoftllc%2Fqc-react-block","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hypersoftllc%2Fqc-react-block/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hypersoftllc%2Fqc-react-block/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hypersoftllc%2Fqc-react-block/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hypersoftllc","download_url":"https://codeload.github.com/hypersoftllc/qc-react-block/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240953064,"owners_count":19884022,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["react-component","semantic"],"created_at":"2025-01-09T22:26:33.976Z","updated_at":"2025-02-26T23:48:14.823Z","avatar_url":"https://github.com/hypersoftllc.png","language":"JavaScript","readme":"# @qc/react-block\n\n[![Build Status][travis-svg]][travis-url]\n[![Coverage Status][coverage-image]][coverage-url]\n[![License][license-image]][license-url]\n[![Downloads][downloads-image]][downloads-url]\n\n[![npm badge][npm-badge-png]][package-url]\n\nA React component that renders a `div` with the semantics of representing a\nblock structure or region.\n\nA `div` is a [block-level element][ble] but by default it does not create a\n[block formatting context][bfc] (BFC).  Certain CSS properties can be applied to\nelements to give it a BFC.  Some of the methods are listed below.\n\n1) Block elements where `overflow` has a value other than `visible`.\n2) Elements with `contain` set to `layout`, `content`, or `strict`.\n3) Elements with `display`'s inside value set to `flow-root`.\n\nA BFC provides the following benefits, among others:\n\n* Prevents top and bottom margin bleedthrough.\n* Lets the background fill the entire area behind an element's content.\n\nSee this [Block Formatting Context for Block-Level Elements][bfc-codepen]\nCodepen to see BFC in action.\n\nNote: Included with the BFC CSS is `box-sizing: border-box` since this is the\nbox-sizing most sensible for a block.\n\nOne of the most common use cases is to use `Block` as the root of a custom\nReact component or as representing different regions within a component.  See\nthe examples below.\n\n\n## Installation\n\n```sh\nnpm install --save @qc/react-block\n```\n\nor\n\n```sh\nyarn add @qc/react-block\n```\n\n\n## Example Usage\n\n**As the Root**\n\n```jsx\nimport React from 'react'\n\nimport Block from '@qc/react-block'\n\nimport '@qc/react-block/dist/styles/Block.css'\n\n\nexport default function MyBlockComponent(props) {\n  return (\n    \u003cBlock className=\"My\" style={{ backgroundColor: '#bedfed' }}\u003e\n      \u003ch1\u003eMy Block Component\u003c/h1\u003e\n      {/*\n      Note: The margins of the `h1` and `p` won't bleed-through\n      like they would with default styled `div`s.  Also, the\n      background color will fill the area behind the margins.\n      */}\n      \u003cp\u003eMy component demo'ing the Block component.\u003c/p\u003e\n    \u003c/Block\u003e\n  )\n}\n```\n\n**Component Regions**\n\n```jsx\nimport React from 'react'\n\nimport Block from '@qc/react-block'\n\nimport '@qc/react-block/dist/styles/Block.css'\n\n\nexport default function Panel(props) {\n  return (\n    \u003cBlock className=\"Panel\"\u003e\n      \u003cBlock className=\"Panel-Head\"\u003e\n        \u003cTitle\u003ePanel's Title\u003c/Title\u003e\n      \u003c/Block\u003e\n      \u003cBlock className=\"Panel-Body\"\u003e\n        \u003ch1\u003e...\u003c/h1\u003e\n        \u003cp\u003e...\u003c/p\u003e\n        \u003ch2\u003e...\u003c/h2\u003e\n        \u003cp\u003e...\u003c/p\u003e\n      \u003c/Block\u003e\n      \u003cBlock className=\"Panel-Foot\"\u003e\n        \u003cbutton\u003e...\u003c/button\u003e\n      \u003c/Block\u003e\n    \u003c/Block\u003e\n  )\n}\n```\n\n**Custom Component Type**\n\n`div`s are not the only element supported.  Any one of the following elements\nmay be used by setting the `compType` property.\n\n* `address`\n* `article`\n* `aside`\n* `blockquote`\n* `details`\n* `div`\n* `dl`\n* `fieldset`\n* `figcaption`\n* `figure`\n* `footer`\n* `form`\n* `header`\n* `main`\n* `nav`\n* `section`\n\n```jsx\nimport React from 'react'\n\nimport Block from '@qc/react-block'\n\nimport '@qc/react-block/dist/styles/Block.css'\n\n\nexport default function SiteFooter(props) {\n  return (\n    \u003cBlock compType=\"footer\"\u003e\n      ...\n    \u003c/Block\u003e\n  )\n}\n```\n\n**Just Using `Block` CSS**\n\nThe key to the `Block` component is in the CSS — not the JavaScript.  All that\nneeds to be done is to include the `Block` CSS class in any\u003csup\u003e†\u003c/sup\u003e\ncomponent.\n\n```jsx\nimport React from 'react'\n\nimport '@qc/react-block/dist/styles/Block.css'\n\n\nexport default function SiteFooter(props) {\n  return (\n    \u003cfooter className=\"Block\"\u003e\n      ...\n    \u003c/footer\u003e\n  )\n}\n```\n\n\u003csup\u003e†\u003c/sup\u003e Excluding [replaced elements].\n\n\n## Use ES Modules\n\nThis package also comes with the source and an ES variation.  Instead of\n\n```jsx\nimport Block from '@qc/react-block'\n```\n\nuse\n\n```jsx\nimport Block from '@qc/react-block/es/Block'\n```\n\nor\n\n```jsx\nimport Block from '@qc/react-block/src/Block'\n```\n\nto import the component.\n\nIf you do this, then you will need to be sure to transpile the code to a syntax\ncompatible with the browsers you plan to support.\n\nThe source is using object spread syntax.  In order to transpile it with\n[babel], you must include the [object spread transform\nplugin][babel-obj-sprd-txm].\n\n\n## Why Multiple BFC Methods?\n\nWhy are multiple BFC methods employed in the included CSS?\n\nThis is to help ensure the block is still given a BFC if in the event that the\nCSS is overridden in a way that would have removed the BFC.  For instance, in\nbrowsers that support `contain: layout` or `display: flow-root`, the following\nwill still have a BFC.\n\n```jsx\n\u003cBlock style={{overflow: 'visible'}}\u003e\n  ...\n\u003c/Block\u003e\n```\n\n\n## Other Packages from [QC]\n\n* [@qc/react-conditionals][qc-react-conditionals]\n* [@qc/react-layer][qc-react-layer]\n* [@qc/react-page][qc-react-page]\n\n\n## Maintainers\n\n- [Danny Hurlburt](https://github.com/dhurlburtusa)\n\n\n## License\n\nISC\n\n\n[babel]: https://babeljs.io/\n[babel-obj-sprd-txm]: https://babeljs.io/docs/plugins/transform-object-rest-spread/\n[bfc]: https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Block_formatting_context\n[bfc-codepen]: https://codepen.io/dhurlburtusa/pen/GxdBJX?editors=1100\n[ble]: https://developer.mozilla.org/en-US/docs/Web/HTML/Block-level_elements\n[coverage-image]: https://coveralls.io/repos/github/hypersoftllc/qc-react-block/badge.svg?branch=master\n[coverage-url]: https://coveralls.io/github/hypersoftllc/qc-react-block?branch=master\n[downloads-image]: http://img.shields.io/npm/dm/@qc/react-block.svg\n[downloads-url]: http://npm-stat.com/charts.html?package=@qc/react-block\n[license-image]: http://img.shields.io/npm/l/@qc/react-block.svg\n[license-url]: LICENSE\n[package-url]: https://npmjs.org/package/@qc/react-block\n[npm-badge-png]: https://nodei.co/npm/@qc/react-block.png?downloads=true\u0026stars=true\n[qc]: https://www.npmjs.com/~qc\n[qc-react-conditionals]: https://www.npmjs.com/package/@qc/react-conditionals\n[qc-react-layer]: https://www.npmjs.com/package/@qc/react-layer\n[qc-react-page]: https://www.npmjs.com/package/@qc/react-page\n[replaced elements]: https://developer.mozilla.org/en-US/docs/Web/CSS/Replaced_element\n[travis-svg]: https://travis-ci.org/hypersoftllc/qc-react-block.svg?branch=master\n[travis-url]: https://travis-ci.org/hypersoftllc/qc-react-block\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhypersoftllc%2Fqc-react-block","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhypersoftllc%2Fqc-react-block","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhypersoftllc%2Fqc-react-block/lists"}