npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

lip-portfolio

v1.0.26

Published

The lip Portfolio Package provides a utility hook, provider and types to simplify working with portfolio data in multiple templates.

Downloads

368

Readme

Lipaa Portfolio

The Lipaa Portfolio Package provides a utility hook, provider and types to simplify working with portfolio data in multiple templates. This package includes:

  • usePortfolio: A React hook that fetches and provides utility functions for extracting data such as: template's theme color, profile information, social platforms information, products information, brands information, recommendations information, collaborations information, social analytics information, total audience information, largest audience information, best-performing social platform information, most recent YouTube video information.
  • PortfolioProvider: A context provider to wrap components for accessing portfolio data.
  • metricIcons and socialIcons: Icons for metrics and social platforms.
  • types and interfaces for strong TypeScript support.

Installation

To use the package in your project, install it via npm or yarn:

npm install lip-portfolio

or

yarn add lip-portfolio

Usage

PortfolioProvider

The PortfolioProvider component wraps your application or component where portfolio data is needed.

Example:

import { PortfolioProvider } from 'lip-portfolio';

function App() {
  const searchParams = new URLSearchParams(window.location.search);
  const baseUrl = process.env.API_BASE_URL;
  const accesssId = process.env.PORTFOLIO_ACCESS_ID;

  const useDefaultData = accesssId === 'DEFAULT';

  const apiUrl = `${baseUrl}/portfolios/${accesssId}?isAnon=true&draft=${searchParams.get(
    'draft'
  )}`;

  return (
    <PortfolioProvider useDefaultData={useDefaultData} apiUrl={apiUrl}>
      <YourComponent />
    </PortfolioProvider>
  );
}

usePortfolio

The usePortfolio hook provides access to portfolio data within a component.

Example:

import { usePortfolio } from 'lip-portfolio';

const defaultProfile: PortfolioProfile = {
  id: '1',
  portfolioId: 'my-portfolio-id',
  draft: null,
  createdAt: new Date().toISOString(),
  updatedAt: new Date().toISOString(),
  displayName: 'Jeffrey Omoore',
  about: `A Designer and Content creator based in Utah, USA. Creating videos to inspire and spark creativity.`,
  contactEmail: '[email protected]',
  profession: 'Video & Content Creator',
  coverImageUrl: '/template-1/hero-image.png',
};

function YourComponent() {
  const { getProfile } = usePortfolio();

  const profile = getProfile(defaultProfile);

  return (
    <div>
      <h1>{profile.displayName}</h1>
    </div>
  );
}

Types and Interfaces

The package includes several TypeScript interfaces for type safety, such as Portfolio, PortfolioProfile, PortfolioSocialPlatform, and more.

Example:

import { PortfolioProfile } from 'lip-portfolio';

const userProfile: PortfolioProfile = {
  id: '1',
  portfolioId: 'my-portfolio-id',
  draft: null,
  createdAt: new Date().toISOString(),
  updatedAt: new Date().toISOString(),
  displayName: 'Jeffrey Omoore',
  about: `A Designer and Content creator based in Utah, USA. Creating videos to inspire and spark creativity.`,
  contactEmail: '[email protected]',
  profession: 'Video & Content Creator',
  coverImageUrl: '/template-1/hero-image.png',
};

API Documentation

Types

  • SupportedPlatforms
  • SupportedSocialLinks
  • Portfolio
  • PortfolioProfile
  • PortfolioSocialAnalytics
  • PortfolioSocialLink
  • PortfolioNotification
  • PortfolioRecommendation
  • PortfolioProduct
  • PortfolioCollaboration
  • PortfolioBrand
  • PortfolioSocialPlatform
  • PortfolioResponse
  • ErrorProps
  • SuccessProps
  • FetchState
  • MutateState
  • Maybe
  • SendMessagePayload
  • SendMessageProps
  • UsePortfolio
  • PortfolioProviderProps

usePortfolio

This hook returns portfolio-related data and actions:

Returned Values:
  • **portfolio**: The portfolio object returns the following:
    • isError: Indicates if there was an error fetching the data.
    • isSuccess: Indicates if the query was successful.
    • error: Contains error details if an error occurs during data fetching.
    • getTemplateThemeColor(defaultData): Returns the template's theme color, or the defaultData if unavailable.
    • getProfile(defaultData): Returns the portfolio profile, or defaultData if unavailable.
    • getSocialPlatforms(defaultData): Returns social platforms linked to the portfolio, or defaultData if unavailable.
    • getProducts(defaultData): Returns portfolio products, or defaultData if unavailable.
    • getBrands(defaultData): Returns the brands associated with the portfolio, or defaultData if unavailable.
    • getRecommendations(defaultData): Returns portfolio recommendations, or defaultData if unavailable.
    • getCollaborations(defaultData): Returns collaborations related to the portfolio, or defaultData if unavailable.
    • getSocialAnalytics(defaultData): Returns social analytics data, or defaultData if unavailable.
    • getTotalAudience(defaultData): Returns the total audience count across all platforms.
    • getLargestAudience(defaultData): Returns the platform with the largest audience, or null if unavailable.
    • getBestPerformingPlatform(defaultData): Returns the best-performing social platform, or null if unavailable.
    • getLatestYoutubeVideo(defaultData): Returns the most recent YouTube video, or null if unavailable.
  • **contact**: The contact object returns the following:
    • hasAccessToMediaKit(code): Checks if the user has access to the media kit based on the provided code.
    • sendMessage({onMutate, onSuccess, onError, payload}): Sends a message to the portfolio owner.
      • onMutate: A callback function to be executed before sending the message.
      • onSuccess: A callback function to be executed after sending the message successfully.
      • onError: A callback function to be executed if there's an error sending the message.
      • payload: The message payload.

PortfolioProvider

The PortfolioProvider component fetches portfolio data and provides it to child components via React's Context API.

Props:

loader: Optional. A custom loader component to display while data is being fetched. error: Optional. A custom error component to display if fetching data fails. apiBaseUrl: Required. The backend api url. accessId: Required. The portfolio access id. isDraft: Required. whether you would like to fetch draft changes or not.

Example:

function renderLoader() {
  return <CustomLoader />;
}

function renderError() {
  return <CustomError />;
}

<PortfolioProvider
  loader={renderLoader}
  error={renderError}
  apiBaseUrl='apiBaseUrl'
  accessId='accessId'
  isDraft={false}
>
  <YourComponent />
</PortfolioProvider>;

For questions, issues, or contributions, feel free to open a GitHub issue or submit a pull request!