1.0.5 • Published 1 year ago

slotty v1.0.5

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

slotty

Simple React slots

NPM

Install

npm i slotty

Usage

import * as React from 'react';
import * as ReactDOM from 'react-dom';

import { Slot, Fill, SlotProvider } from 'slotty';

const App = () => {
  const [fillSlot1, setFillSlot1] = React.useState(true);
  const [fillSlot2, setFillSlot2] = React.useState(true);

  return (
    <SlotProvider>
      <div className="App">
        <Slot name="title">
          <h1>Title</h1>
        </Slot>

        <Slot name="subtitle" />

        {fillSlot1 && (
          <Fill slot="title">
            <h1>Custom title</h1>
          </Fill>
        )}

        {fillSlot2 && (
          <Fill slot="subtitle">
            <h2>Custom subtitle</h2>
          </Fill>
        )}

        <hr />
        <button onClick={() => setFillSlot1(!fillSlot1)}>
          Filling slot 1: {fillSlot1 ? 'Yes' : 'No'}
        </button>
        <button onClick={() => setFillSlot2(!fillSlot2)}>
          Filling slot 2: {fillSlot2 ? 'Yes' : 'No'}
        </button>
      </div>
    </SlotProvider>
  );
};

ReactDOM.render(<App />, document.getElementById('root'));

License

MIT © EmreErdogan

1.0.5

1 year ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago