### Setting Up React Trello Development Environment Source: https://github.com/kaispencer/react-trello-ts/blob/main/react-trello-README.md This snippet outlines the essential steps to set up the development environment for the `react-trello` project. It includes navigating to the project directory, installing necessary dependencies using `yarn install`, and starting the Storybook development server. ```Bash cd react-trello/ yarn install yarn run storybook ``` -------------------------------- ### Installing React Trello TS Library Source: https://github.com/kaispencer/react-trello-ts/blob/main/README.md These snippets provide instructions for installing the `react-trello-ts` library using either npm or yarn package managers. Both commands add the library as a dependency to your project. ```bash $ npm install --save react-trello-ts ``` ```bash $ yarn add react-trello-ts ``` -------------------------------- ### Installing React Trello with Yarn Source: https://github.com/kaispencer/react-trello-ts/blob/main/react-trello-README.md This snippet shows how to install the `react-trello` library using the Yarn package manager. This command adds the package as a dependency to your project. ```bash $ yarn add react-trello ``` -------------------------------- ### Installing React Trello with npm Source: https://github.com/kaispencer/react-trello-ts/blob/main/react-trello-README.md This snippet demonstrates how to install the `react-trello` library using the npm package manager. The `--save` flag adds the package as a dependency to your project's `package.json` file. ```bash $ npm install --save react-trello ``` -------------------------------- ### Installing Edge Version of React Trello with Yarn Source: https://github.com/kaispencer/react-trello-ts/blob/main/react-trello-README.md This command installs the current master branch (edge version) of `react-trello` directly from the GitHub repository using Yarn. This is useful for accessing the latest features or bug fixes before they are officially released. ```bash $ yarn add rcdexta/react-trello ``` -------------------------------- ### Integrating react-i18next with React Trello Source: https://github.com/kaispencer/react-trello-ts/blob/main/react-trello-README.md This example demonstrates how to integrate `react-i18next` for internationalization by wrapping the `Board` component with the `withTranslation` higher-order component. This allows the `Board` component to access translation capabilities provided by `react-i18next`. ```JavaScript import { withTranslation } from 'react-i18next'; const I18nBoard = withTranslation()(Board) ``` -------------------------------- ### Handling Card Drag Start in React Trello TS (TypeScript) Source: https://github.com/kaispencer/react-trello-ts/blob/main/react-trello-README.md This callback function is triggered when a card drag operation begins. It provides the IDs of the card and its originating lane, allowing for custom logic to be executed at the start of a drag. ```TypeScript handleDragStart(cardId: string, laneId: string) ``` -------------------------------- ### Applying Predefined CSS Classes for React Trello Elements Source: https://github.com/kaispencer/react-trello-ts/blob/main/react-trello-README.md This snippet demonstrates how to use the predefined CSS classnames (`.react-trello-lane`, `.react-trello-card`, `.react-trello-board`) to apply custom styles to React Trello components. It provides an example for styling the `.react-trello-lane` element. ```CSS .react-trello-lane { border: 0; background-color: initial; } ``` -------------------------------- ### Handling Lane Drag Start in React Trello TS (TypeScript) Source: https://github.com/kaispencer/react-trello-ts/blob/main/react-trello-README.md This callback function is triggered when a lane drag operation begins. It provides the ID of the lane being dragged, enabling custom logic to be executed at the start of a lane drag. ```TypeScript handleLaneDragStart(laneId: string) ``` -------------------------------- ### Publishing Events to React Trello Board Source: https://github.com/kaispencer/react-trello-ts/blob/main/react-trello-README.md This example demonstrates how to obtain an event bus handle from the `Board` component to publish events programmatically after the board has rendered. It includes various event types for manipulating cards (add, update, remove, move) and lanes, enabling real-time state changes. ```JavaScript let eventBus = undefined const setEventBus = (handle) => { eventBus = handle } //To add a card eventBus.publish({type: 'ADD_CARD', laneId: 'COMPLETED', card: {id: "M1", title: "Buy Milk", label: "15 mins", description: "Also set reminder"}}) //To update a card eventBus.publish({type: 'UPDATE_CARD', laneId: 'COMPLETED', card: {id: "M1", title: "Buy Milk (Updated)", label: "20 mins", description: "Also set reminder (Updated)"}}) //To remove a card eventBus.publish({type: 'REMOVE_CARD', laneId: 'PLANNED', cardId: "M1"}) //To move a card from one lane to another. index specifies the position to move the card to in the target lane eventBus.publish({type: 'MOVE_CARD', fromLaneId: 'PLANNED', toLaneId: 'WIP', cardId: 'Plan3', index: 0}) //To update the lanes eventBus.publish({type: 'UPDATE_LANES', lanes: newLaneData}) ``` -------------------------------- ### Importing Edge Version of React Trello Board Source: https://github.com/kaispencer/react-trello-ts/blob/main/react-trello-README.md This JavaScript import statement is used when consuming the edge version of `react-trello`. Instead of importing from the root package, it specifically imports the `Board` component from the `src` directory of the installed edge version. ```javascript import Board from 'react-trello/src' ``` -------------------------------- ### Implementing Custom Text Translation for React Trello Source: https://github.com/kaispencer/react-trello-ts/blob/main/react-trello-README.md This snippet shows how to integrate custom text translation by passing a translation function to the `Board` component's `t` prop. It provides examples for both flat and nested translation tables, utilizing `createTranslate` from `react-trello` for nested structures. ```JavaScript // If your translation table is flat // // For example: { 'placeholder.title': 'some text' } const customTranslation = (key) => TRANSLATION_TABLE[key] // If your translation table has nested hashes (provided translations table is it) // // For example: { 'placeholder': { 'title': 'some text' } } import { createTranslate } from 'react-trello' const customTranslation = createTranslate(TRANSLATION_TABLE) ``` -------------------------------- ### Rendering React Trello Board Component Source: https://github.com/kaispencer/react-trello-ts/blob/main/react-trello-README.md This React component demonstrates the basic usage of the `Board` component from `react-trello`. It imports `React` and `Board`, then renders the `Board` component, passing the previously defined `data` object as a prop to display the kanban board. ```jsx import React from 'react' import Board from 'react-trello' export default class App extends React.Component { render() { return } } ``` -------------------------------- ### React Trello Development Scripts Source: https://github.com/kaispencer/react-trello-ts/blob/main/react-trello-README.md This section lists various `yarn` scripts available for common development tasks within the `react-trello` project. These scripts cover linting, testing, building, and documentation generation, streamlining the development workflow. ```Bash yarn run lint yarn run lintfix yarn run semantic-release yarn run storybook yarn run test yarn run test:watch yarn run test:cover yarn run test:report yarn run build yarn run docs ``` -------------------------------- ### Customizing React Trello Components via Dependency Injection Source: https://github.com/kaispencer/react-trello-ts/blob/main/react-trello-README.md This snippet illustrates how to completely override default components (e.g., `GlobalStyle`, `LaneHeader`, `Card`, `AddCardLink`) by providing custom component implementations to the `Board` component via its `components` prop. This offers full control over the look and feel of the board. ```JavaScript const components = { GlobalStyle: MyGlobalStyle, // global style created with method `createGlobalStyle` of `styled-components` LaneHeader: MyLaneHeader, Card: MyCard, AddCardLink: MyAddCardLink, ... }; ``` -------------------------------- ### Board Components Map Customization - JavaScript Source: https://github.com/kaispencer/react-trello-ts/blob/main/UPGRADE.md This snippet demonstrates the new way to customize `react-trello` components in version 2.2 using the `components` prop. It accepts an object mapping component keys to their respective React components, providing a centralized and flexible approach for customization. ```javascript const components = { AddCardLink: () => , LaneHeader: CustomLaneHeader, NewCardForm: NewCard, NewLaneSection: NewLane, Card: CustomCard }; ``` -------------------------------- ### Legacy Board Component Customization - JavaScript Source: https://github.com/kaispencer/react-trello-ts/blob/main/UPGRADE.md This snippet illustrates the deprecated method of customizing `react-trello` components using direct props like `addCardLink`, `customLaneHeader`, `newCardTemplate`, `newLaneTemplate`, and `customCardLayout` with children. These properties are removed in version 2.2 and replaced by a `components` map. ```javascript New Card} customLaneHeader={} newCardTemplate ={} newLaneTemplate ={} customCardLayout > ``` -------------------------------- ### Defining React Trello Board Data Structure Source: https://github.com/kaispencer/react-trello-ts/blob/main/react-trello-README.md This JavaScript object defines the required data structure for the `react-trello` board component. It includes an array of `lanes`, each containing an `id`, `title`, `label`, and an array of `cards`. Cards can have properties like `id`, `title`, `description`, `label`, `draggable`, and `metadata`. ```javascript const data = { lanes: [ { id: 'lane1', title: 'Planned Tasks', label: '2/2', cards: [ {id: 'Card1', title: 'Write Blog', description: 'Can AI make memes', label: '30 mins', draggable: false}, {id: 'Card2', title: 'Pay Rent', description: 'Transfer via NEFT', label: '5 mins', metadata: {sha: 'be312a1'}} ] }, { id: 'lane2', title: 'Completed', label: '0/0', cards: [] } ] } ``` -------------------------------- ### Legacy Board Text Properties - JavaScript Source: https://github.com/kaispencer/react-trello-ts/blob/main/UPGRADE.md This snippet demonstrates the deprecated way of setting text properties like `addLaneTitle` and `addCardLink` directly on the `Board` component in `react-trello` version 2.1. These properties have been removed in version 2.2 and should be replaced with a translation function. ```javascript ``` -------------------------------- ### Board Translation Function Usage - JavaScript Source: https://github.com/kaispencer/react-trello-ts/blob/main/UPGRADE.md This snippet shows the recommended approach for customizing texts in `react-trello` version 2.2. It utilizes the `createTranslate` function from `react-trello` to provide a translation map, which is then passed to the `Board` component via the `t` prop, replacing direct text properties. ```javascript import { createTranslate } from 'react-trello' const TEXTS = { "Add another lane": "NEW LANE", "Click to add card": "Click to add card", "Delete lane": "Delete lane", "Lane actions": "Lane actions", "button": { "Add lane": "Add lane", "Add card": "ADD CARD", "Cancel": "Cancel" }, "placeholder": { "title": "title", "description": "description", "label": "label" } } ``` -------------------------------- ### Handling Lane Add in React Trello TS (TypeScript) Source: https://github.com/kaispencer/react-trello-ts/blob/main/react-trello-README.md This callback function is invoked when a new lane is successfully added to the board. It provides the parameters used to create the new lane, allowing for custom logic after a lane has been added. ```TypeScript onLaneAdd(params: any) ``` -------------------------------- ### Handling Card Click in React Trello TS (TypeScript) Source: https://github.com/kaispencer/react-trello-ts/blob/main/react-trello-README.md This callback function is triggered when a card is clicked. It provides the card's ID, any associated metadata, and the ID of the lane it belongs to, enabling custom actions upon card selection. ```TypeScript onCardClick(cardId: string, metadata: any, laneId: string) ``` -------------------------------- ### Handling Data Change in React Trello TS (TypeScript) Source: https://github.com/kaispencer/react-trello-ts/blob/main/react-trello-README.md This callback function is invoked every time the board's underlying data structure changes, whether due to user interaction or an event bus. It provides the updated data, allowing for persistence or state management. ```TypeScript onDataChange(newData: any) ``` -------------------------------- ### Handling Before Card Delete in React Trello TS (TypeScript) Source: https://github.com/kaispencer/react-trello-ts/blob/main/react-trello-README.md This callback function is triggered just before a card is deleted. It requires calling the provided callback() function to confirm and proceed with the deletion, allowing for confirmation prompts or pre-deletion logic. ```TypeScript onBeforeCardDelete(callback: () => void) ``` -------------------------------- ### Handling Card Add in React Trello TS (TypeScript) Source: https://github.com/kaispencer/react-trello-ts/blob/main/react-trello-README.md This callback function is invoked when a new card is successfully added to the board. It provides the details of the newly added card and the ID of the lane it was added to, allowing for post-add processing. ```TypeScript onCardAdd(card: any, laneId: string) ``` -------------------------------- ### Applying Custom Styles via Data Props in React Trello Source: https://github.com/kaispencer/react-trello-ts/blob/main/react-trello-README.md This method allows passing custom style attributes directly within the `data` object for individual lanes and cards, as well as for the `Board` component itself. This approach provides granular control over component styling and depends on the specific `Card` and `Lane` components used. ```JavaScript const data = { lanes: [ { id: 'lane1', title: 'Planned Tasks', style: { backgroundColor: 'yellow' }, // Style of Lane cardStyle: { backgroundColor: 'blue' } // Style of Card ... }; ``` -------------------------------- ### Handling Card Move Across Lanes in React Trello TS (TypeScript) Source: https://github.com/kaispencer/react-trello-ts/blob/main/react-trello-README.md This callback function is triggered when a card is moved from one lane to another. It provides the IDs of the source and target lanes, the card's ID, and its new index within the target lane, facilitating updates to data models. ```TypeScript onCardMoveAcrossLanes(fromLaneId: string, toLaneId: string, cardId: string, index: number) ``` -------------------------------- ### Handling Lane Click in React Trello TS (TypeScript) Source: https://github.com/kaispencer/react-trello-ts/blob/main/react-trello-README.md This callback function is triggered when a lane is clicked. It provides the ID of the clicked lane. Note that card click events are not propagated to this handler, ensuring distinct handling for cards and lanes. ```TypeScript onLaneClick(laneId: string) ``` -------------------------------- ### Handling Lane Scroll in React Trello TS (TypeScript) Source: https://github.com/kaispencer/react-trello-ts/blob/main/react-trello-README.md This callback function is invoked when a lane is scrolled to its end, typically used for implementing infinite scrolling or lazy loading of cards. It provides the requested page number and the ID of the scrolled lane. ```TypeScript onLaneScroll(requestedPage: number, laneId: string) ``` -------------------------------- ### Handling Card Drag End in React Trello TS (TypeScript) Source: https://github.com/kaispencer/react-trello-ts/blob/main/react-trello-README.md This callback function is triggered when a card drag operation concludes. It provides details about the card, its source and target lanes, its new position, and full card details. Returning false from this function will cancel the drop operation. ```TypeScript handleDragEnd(cardId: string, sourceLaneId: string, targetLaneId: string, position: number, cardDetails: any) ``` -------------------------------- ### Handling Lane Update in React Trello TS (TypeScript) Source: https://github.com/kaispencer/react-trello-ts/blob/main/react-trello-README.md This callback function is invoked when a lane's attributes are updated. It provides the ID of the updated lane and the new data, enabling custom logic to respond to lane modifications. ```TypeScript onLaneUpdate(laneId: string, data: any) ``` -------------------------------- ### Handling Lane Drag End in React Trello TS (TypeScript) Source: https://github.com/kaispencer/react-trello-ts/blob/main/react-trello-README.md This callback function is triggered when a lane drag operation concludes. It provides the original and new indices of the lane, along with a payload containing the lane's data, allowing for updates based on the reordering. ```TypeScript handleLaneDragEnd(removedIndex: number, addedIndex: number, payload: any) ``` -------------------------------- ### Handling Lane Delete in React Trello TS (TypeScript) Source: https://github.com/kaispencer/react-trello-ts/blob/main/react-trello-README.md This callback function is invoked when a lane has been deleted from the board. It provides the ID of the deleted lane, allowing for post-deletion cleanup or state synchronization. ```TypeScript onLaneDelete(laneId: string) ``` -------------------------------- ### Handling Card Delete in React Trello TS (TypeScript) Source: https://github.com/kaispencer/react-trello-ts/blob/main/react-trello-README.md This callback function is invoked when a card has been deleted from the board. It provides the ID of the deleted card and the ID of the lane it was removed from, allowing for post-deletion cleanup or logging. ```TypeScript onCardDelete(cardId: string, laneId: string) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.