Giter Site home page Giter Site logo

preact-slots's Introduction

preact-slots npm travis

Render Preact trees into other Preact trees, like portals.

Install

preact-slots is available on npm:

npm install --save preact-slots

Usage

Define "holes" in your appliation using <Slot name="foo" />, then fill them using <SlotContent slot="foo">some content</SlotContent>:

import { SlotProvider, Slot, SlotContent } from 'preact-slots'

render(
    <SlotProvider>
        <div>
            <Slot name="foo">
                Some Fallback Content
            </Slot>
            <SlotContent slot="foo">
                Replacement Content
            </SlotContent>
        </div>
    </SlotProvider>
)

The above renders <div>Replacement Content</div>.

An extended example follows:

import { Slot, SlotContent, SlotProvider } from 'preact-slots'

const Header = () => (
    <header class="header">
        <Slot name="title">Slots Demo</Slot>
        <Slot name="toolbar">
            { items => items && <nav>{items}</nav> }
        </Slot>
    </header>
)

const EditPage = ({ page, content, onSave, onCancel }) => (
    <div class="page-editor">
        <SlotContent slot="title">Editing {page}</SlotContent>
        <SlotContent slot="toolbar">
            <button onClick={onSave}>Save</button>
            <button onClick={onCancel}>Cancel</button>
        </SlotContent>
        <textarea value={content} />
    </div>
)

render(
    <SlotProvider>
        <div class="app">
            <Header />
            <EditPage />
        </div>
    </SlotProvider>
)

Similar Libraries

Slots are a concept that has been around for a while.

In particular, @camwest's react-slot-fill is similar to preact-slots, but geared towards React.

License

MIT License Β© Jason Miller

preact-slots's People

Contributors

developit avatar greenkeeper[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

fwilkerson

preact-slots's Issues

An in-range update of karmatic is breaking the build 🚨

The devDependency karmatic was updated from 1.2.0 to 1.3.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

karmatic is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ continuous-integration/travis-ci/push: The Travis CI build failed (Details).

Release Notes for 1.3.0

🦟 Better Debugging

A new karmatic debug command wraps up a few important flags into one easy to remember debug mode. In this mode, coverage is not reported and Chrome is opened in "headful" mode for visual inspection. (#27, thanks @andrewiggins)

πŸ™ˆ Coverage Reporting

Code coverage reports in HTML and JSON format are now generated by default in a coverage directory. You can also disable these by passing --no-coverage. (#26, thanks @andrewiggins)

πŸ•Έ Custom Browsers

karmatic watch --browsers firefox

🧭 Built-in support for SauceLabs

Set the SAUCE_USERNAME and SAUCE_ACCESS_KEY env vars, then pass saucelabs browser/platform combinations to the new --browsers option:

SAUCE_USERNAME=developit SAUCE_ACCESS_KEY=123456 karmatic --browsers sauce-ie-11,sauce-ie-10

🌢 Modern JS

karmatic now transpiles for modern browsers only (last 2 versions of Chrome + Firefox + Safari). Don't worry though - it'll still transpile down to ES5 if --browsers includes "ie" or "internet explorer", or if the --downlevel flag is set.

Commits

The new version differs by 20 commits.

  • 81f8cf3 1.3.0
  • 277f019 Merge pull request #28 from developit/wip
  • c802b6d Add --downlevel option to manually enable IE9+ compat
  • a656ed7 wip
  • a391c9b Merge pull request #27 from andrewiggins/debug-option
  • bf6f0b0 Merge branch 'master' into debug-option
  • 38b3e9e Merge pull request #25 from andrewiggins/update-deps
  • 056363c Merge branch 'master' into update-deps
  • 436182b Merge pull request #24 from ianwalter/master
  • 382cf9d Merge pull request #26 from andrewiggins/coverage
  • 23b8e57 Merge branch 'master' into master
  • 1b8d04f Merge branch 'master' into debug-option
  • fb8b7fb Merge branch 'master' into coverage
  • d2dbeeb Merge branch 'master' into update-deps
  • 4ae5ece add example repo

There are 20 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of microbundle is breaking the build 🚨

Version 0.4.5 of microbundle was just published.

Branch Build failing 🚨
Dependency microbundle
Current Version 0.4.4
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

microbundle is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ continuous-integration/travis-ci/push The Travis CI build failed Details

Commits

The new version differs by 63 commits.

  • 6a95870 0.4.5
  • 41e0dc3 Fix mangle.json name caching (seemed to break in a recent rollup update)
  • 42050bb Fix Rollup upgrade adding __esModule properties to exports.
  • 0a6a791 Merge pull request #161 from philipp-spiess/patch-1
  • 1ffccee Add react-recomponent to "Built with Microbundle"
  • bf2d068 Updated rollup to 0.60.1, made code changes to support it (#151)
  • 8286def Merge pull request #153 from mattdesl/fix/111
  • fcbfa8f Merge pull request #149 from developit/greenkeeper/pretty-bytes-5.1.0
  • d786f03 fix #111 and log errors during watch
  • 8393af2 fix(package): update pretty-bytes to version 5.1.0
  • 818a7d5 Revert "Update rollup to the latest version πŸš€" (#148)
  • c7fbe3e Merge pull request #145 from developit/greenkeeper/rollup-0.60.0
  • 9d77676 fix(package): update rollup to version 0.60.0
  • 4d5ff56 Turn off eslint rules inconsistent with prettier settings and run prettier through eslint (#136)
  • 3afc4f4 Merge pull request #140 from developit/greenkeeper/rollup-0.59.3

There are 63 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of preact is breaking the build 🚨

Version 8.3.0 of preact was just published.

Branch Build failing 🚨
Dependency preact
Current Version 8.2.9
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

preact is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ continuous-integration/travis-ci/push: The Travis CI build failed (Details).

Release Notes 8.3.0

New Features!

πŸ™Œ We've added support for the new getDerivedStateFromProps() and getSnapshotBeforeUpdate() lifecycle hooks. (#1094 & #1112). A huge thank-you to @andrewiggins and @marvinhagemeister for their amazing work on this!

Improvements

  • We're shipping .mjs now! (#1165, thanks @mathiasbynens for the nudge)
  • Fix an issue where setState() could mutate state in-place (#1170, thanks @Mitranim for the fix and @dandv for digging into the Apollo issue!)
  • spellcheck={false} is now set as an attribute (#1110, thanks @marvinhagemeister!)
  • Some code golfing to offset the new lifecycle methods (#1122, thanks @andrewiggins, @marvinhagemeister)
  • A little perf/size tweak for render callbacks (#1113, thanks @valotas)
  • Someone found dead code in Preact! awesome. (#890, thanks @MrErHu & @clarkdo)
  • We've dropped IE9 and IE10 from our SauceLabs tests (thanks @mkxml!)

    Note: Preact will continue to support these browsers (that is to say, continue to avoid relying on features they don't support), but recent updates to Mocha mean our tests don't run there. Special thanks to @mkxml, @andrewiggins, @k1r0s and @marvinhagemeister for working to improve the test suite in this release!

TypeScript Improvements!

  • Add support for specifying the types of a component's children (#1116, thanks @Alexendoo)
  • Add on*Capture event handler attributes and PointerEvents to the TS definitions (#1101 #1102, thanks @jakearchibald)
  • Improve render()'s return type (#1085, thanks @valotas)
  • Add controlsList attribute for media elements (#1134, thanks @wayou)
Commits

The new version differs by 70 commits.

  • 8dea9cc 8.3.0
  • 7cbaa2a Save 30b by removing sharding from the component recycler. It was actually slightly hurting performance in everything but PhantomJS.
  • 013c060 Merge pull request #1175 from feross/patch-1
  • 17f6d09 Add BitMidi; add link to Play.cash repo
  • 5410c7e Merge pull request #1170 from Mitranim/master
  • 576c891 getDerivedStateFromProps now creates new versions instead of mutating state
  • ea932dd setState now creates new versions instead of mutating state
  • b8a117a Use .mjs extn for module entry & strip comments (#1166)
  • 5ed8e08 Change dist module extension to .mjs and strip comments. Fixes #1165
  • 9febcaf Merge pull request #1163 from andrewiggins/prev-props-and-state-uts
  • c10d705 Remove TODO
  • b2582ef Simplify tests by removing log concept
  • 899aa6e Separate testing new props and new state
  • 3ab0f4d Add gDSFP params test
  • 4c5b361 Add nextState, etc. test for shouldComponentUpdate

There are 70 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of preact-context-provider is breaking the build 🚨

Version 1.1.0 of preact-context-provider was just published.

Branch Build failing 🚨
Dependency preact-context-provider
Current Version 1.0.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

preact-context-provider is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ continuous-integration/travis-ci/push The Travis CI build could not complete due to an error Details

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of preact is breaking the build 🚨

The devDependency preact was updated from 8.3.1 to 8.4.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

preact is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ continuous-integration/travis-ci/push: The Travis CI build failed (Details).

Release Notes for 8.4.0

The cat is out of the bag πŸ™Œ We finally revealed on what we have in store
for the next major version of preact which will be called Preact X πŸŽ‰ To give
you a sneak peak of what will be included check out this talk over at this.javascript
video, slides.
It's hard to make an estimate right now on when it will be released, but rest
assured we are nearly done and are working on upgrading the ecosystem
(cli, router,...) to ensure a smooth release.

That said we very excited about recent community contributions. This release
contains some awesome performance enhancements brought to you by @lowaa and
@rpetrich. On top of that there are some minor bug fixes and a lots of
improvements to our typings.

Thank you so much for everyone involved πŸ‘

TypeScript Improvements!

Flow improvements!

README Improvements!

Commits

The new version differs by 79 commits ahead by 79, behind by 3.

  • 3a35a89 8.4.0
  • 86c7e5a udpate deps
  • 19f77d3 Merge pull request #1251 from garybernhardt/npm_installable_from_git
  • ca2cb6c Merge branch 'master' into npm_installable_from_git
  • 95075f4 Added "onInvalid" form event in TS (#1221)
  • 58e1927 Build properly when installing from git
  • 377e31b [types] Add more type tests for h function (#1246)
  • 3bbcdcc Merge pull request #1214 from garybernhardt/reverse_h_type_definition_order
  • 0aece17 Merge branch 'master' into reverse_h_type_definition_order
  • b243a5e Merge pull request #1249 from scurker/typescript/any-component
  • 42c92b6 fix AnyComponent with ComponentConstructor
  • cd807ce Merge pull request #1244 from JiLiZART/patch-1
  • 47cd310 Merge branch 'master' into patch-1
  • 7dda9a2 Merge pull request #1248 from wojtczal/fix-inconsistent-key-property-type
  • f3d7a71 use Key type for Attributes interface key property

There are 79 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of preact-context-provider is breaking the build 🚨

The devDependency preact-context-provider was updated from 1.1.1 to 1.2.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

preact-context-provider is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ continuous-integration/travis-ci/push: The Travis CI build failed (Details).

Release Notes for Add getWrappedComponent() function to provide and mergingProvide decorated components

In order to help with unit testing (and likely other scenarios) the getWrappedComponent() method has been added to all decorator functions. This combines with the same function provided by other related libraries like wiretie, preact-i18n, and preconf so that it is easier to get the underlying decorated component for the purpose of spying/stubbing on methods in unit tests without having to arbitrarily export an unwrapped version of the component from the module.

Commits

The new version differs by 4 commits.

  • 04bfff5 Merge pull request #6 from synacor/getWrappedComponent
  • 31be981 getWrappedComponent fix test script
  • 754b974 add getWrappedComponent method to provide and mergingProvide decorators
  • 937928c update dependencies

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of karmatic is breaking the build 🚨

Version 1.1.7 of karmatic was just published.

Branch Build failing 🚨
Dependency karmatic
Current Version 1.0.7
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

karmatic is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ continuous-integration/travis-ci/push The Travis CI build failed Details

Commits

The new version differs by 2 commits.

  • 56374af 1.1.7
  • eb51eb3 Add support for Webpack 4 (in addition to 3 & prior)

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.