Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@aller/cyclops-frontend-vanilla

Package Overview
Dependencies
Maintainers
9
Versions
211
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aller/cyclops-frontend-vanilla

Vanilla JS implementation of login-button

  • 2.5.5-alpha.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
9
Weekly downloads
 
Created
Source

cyclops-frontend-vanilla

This package is for vanilla-js DOM-manipulation for cyclops-functions. As of now, it only contains code for injecting the login-button/showing your name in the place of the login-button.

Table of Contents

Functions

injectUser

import { injectUser } from '@aller/cyclops-frontend-vanilla'

injectUser(elementId, domain?, ILoginButton?, withInitials?)

For users that want the least possible bloat, imports should be handled as such:

import { injectUser } from "@aller/cyclops-frontend-vanilla/lib/components/loginButton";

For users that doesn't want to include any CSS for injectUser, use:

import { injectUser } from "@aller/cyclops-frontend-vanilla/lib/generator/generateLoginButton";

Instead of importing everything the index.ts forward-exports, it only imports the element that is wanted/needed. This could help tree-shaking in cases where there are no tree-shaking done on transpiling.

Injects a login-button to the elementId sent in as a parameter and fetches whether the user is logged in.

If you want to test the functionality on a non-relative domain, the domain can also be sent with as a parameter.

If you want generate user-name with initials, you can pass additional argument to this function withInitials in this case two buttons will be generated: one with fullName and another with just initials of user name. This was done to configuration make flexible and if you need one of them you can hide it trough css.

This function can include an object of the type ILoginButton interface for customizable classes and texts. Here are the defaults:

{
  dropdownButtonClass: "cyclops-dropbtn",
  dropdownInitialsButtonClass: "cyclops-dropbtn-initials",
  dropdownContentClass: "cyclops-dropdown-content",
  dropdownClass: "cyclops-dropdown",
  containerContentClass: "cyclops-login",
  loginText: "Logg Inn",
  logoutText: "Logg Ut",
  myPageText: "Minside",
  extraLinks: []
}

For adding more custom elements in the user-dropdown, the property extraLinks can be used. This property can hold elements of the interface:

interface IExtraLink {
  text: string;
  href: string;
}

If the property extraLinks remain empty, there will only be added the default "Minside" and "Logg Ut" buttons. If the extraLinks are defined, these links will appear between the "Minside" and "Logg Ut" links.

injectDynamicContent

import { injectDynamicContent } from '@aller/cyclops-frontend-vanilla'

injectDynamicContent(elementId, productId, studioLink?, plussContentLink?)

For users that doesn't want to include any CSS for injectDynamicContent, use:

import { injectDynamicContent } from "@aller/cyclops-frontend-vanilla/lib/generator/generateLoginButton";

Injects a dynamic content link to the elementId sent in as a parameter and fetches whether the user is logged in.

If user is logged in and has pluss subscription we'll return him link to pluss content. If user is logged in but doesn't have pluss subscription we'll return him link to live content (studio)

injectLoginBox

import { injectLoginBox } from '@aller/cyclops-frontend-vanilla'

injectLoginBox(elementId: string, domain?: string, textClasses?: ILoginBox)

For users that want the least possible bloat, imports should be handled as such:

import { injectLoginBox } from "@aller/cyclops-frontend-vanilla/lib/components/loginBox";

Injects a login-wall/login-box into the document with some customizable classes and texts. elementId defines what element it should be under, domain can be used if you don't want a relative path. textClasses is of the type ILoginBox which can be used to override the default texts and classes.

interface ILoginBox {
  texts?: {
    toSeeText?: string;
    loginText?: string;
    loginaID?: string;
    ifNoPre?: string;
    registerText?: string;
    itsFree?: string;
  };
  classes?: {
    container?: string;
    title?: string;
    subtitle?: string;
    loginButton?: string;
    register?: string;
  };
}

injectSubscriptionBox

import { injectSubscriptionBox } from '@aller/cyclops-frontend-vanilla'

injectSubscriptionBox(
  elementId: string,
  brandId: string,
  productId: string,
  dealId: string,
  _focus: boolean,
  _brands: any[],
  _textsAndClasses?: ISubscriptionBox,
  _paymentOptions?: IPaymentOptions,
  _domain?: string | null)

For users that want the least possible bloat, imports should be handled as such:

import { injectSubscriptionBox } from "@aller/cyclops-frontend-vanilla/lib/components/subscriptionBox";

injectSubscriptionBox injects a subscription-box that either is dynamic from the catalogue, or just inserts based on the _brands included. brandId, productId and dealId is used for verifying that the brand/product/deal actually exists in the inserted _brands. If _brands isn't defined, it logs out an error to the console, since _brands are required.

_focus decides whether the box should have the css-class focus, which can be used to add extra styling to that specific element.

_textsAndClasses contains the different override/extra texts and classes editors can add:

interface ISubscriptionBox {
  texts?: {
    youChoseText?: string;
    bottomText?: string;
    subtitleText?: string;
    label?: string;
    buyButtonText?: string;
    returnUrl?: string;
    termsAndConditionsLink?: string;
  };
  classes?: {
    subscriptionBoxClass?: string;
    dealNameClass?: string;
    labelClass?: string;
    costClass?: string;
    fullTermsClass?: string;
    buyButtonClass?: string;
    dialogClass?: string;
    dialogContentClass?: string;
    dialogProductNameClass?: string;
    dialogCostClass?: string;
    dialogDealNameClass?: string;
    dialogFullTermsClass?: string;
    dialogSubtitleTextClass?: string;
    dialogBuyButtonClass?: string;
    dialogBottomTextClass?: string;
    dialogCloseClass?: string;
    termsAndConditionClass?: string;
  };
}

injectSubscriptionBoxWidthGetter

import { injectSubscriptionBoxWidthGetter } from '@aller/cyclops-frontend-vanilla'

injectSubscriptionBoxWidthGetter(
  elementId: string,
  brandId: string,
  productId: string,
  dealId: string,
  _focus: boolean,
  _brands?: any[],
  _textsAndClasses?: ISubscriptionBox,
  _paymentOptions?: IPaymentOptions,
  _domain?: string | null,
  _options?: any)

For users that want the least possible bloat, imports should be handled as such:

import { injectSubscriptionBoxWidthGetter } from "@aller/cyclops-frontend-vanilla/lib/components/subscriptionBoxWidthGetter";

injectSubscriptionBoxWidthGetter injects a subscription-box that either is dynamic from the catalogue, or just inserts based on the _brands included. brandId, productId and dealId is used for verifying that the brand/product/deal actually exists in the inserted _brands. If _brands isn't defined, the three ID's are used to fetch and populate the correct element from the API.

See injectSubscriptionBox for the rest of the parameters.

generateSubscriptionBox

import { generateSubscriptionBox } from "@aller/cyclops-frontend-vanilla/lib/generator/generateSubscriptionBox";

generateSubscriptionBox(
  id: string,
  focus: boolean,
  deal: IProductDeal,
  textsAndClasses: ISubscriptionBox
)

Very similar to the injector (and is in fact used by the injector), but instead just returns the HTML for the element as a string. This can be used for serverside "rendering" of the element.

generateSubscriptionModal

import { generateSubscriptionModal } from "@aller/cyclops-frontend-vanilla/lib/generator/generateSubscriptionModal";

generateSubscriptionModal(
  id: string,
  deal: IProductDeal,
  product: IProduct,
  pathname: string,
  textsAndClasses: ISubscriptionBox,
  domain?: string
)

Very similar to the injector (and is in fact used by the injector), but instead just returns the HTML for the element as a string. This can be used for serverside "rendering" of the element. The only difference to this, and the above generator, is that since it is a modal, this should have e.g. modal appended to the ID, and the A11yDialog has to be added manually for the modal to actually work.

generateLoginBox

import { generateLoginBox } from "@aller/cyclops-frontend-vanilla/lib/generator/generateLoginBox";

generateLoginBox(
  id: string,
  deal: IProductDeal,
  product: IProduct,
  pathname: string,
  textsAndClasses: ISubscriptionBox,
  domain?: string
)

Very similar to the injector (and is in fact used by the injector), but instead just returns the HTML for the element as a string. This can be used for serverside "rendering" of the element.

generateDialogScript

import { generateDialogScript } from "@aller/cyclops-frontend-vanilla/lib/generator/generateDialogScript";

generateDialogScript(id: string)

This is used to add inline script-tags to trigger the A11yDialog clientside on page-rendered. The ID here must be the same that is sent in with generateSubscriptionModal.

loginBox

import "@aller/cyclops-frontend-vanilla/lib/client/loginBox";

This is used to add the needed CSS for the login-box, if going the server-side rendering way.

subscriptionBox

import "@aller/cyclops-frontend-vanilla/lib/client/subscriptionBox";

This is used to add the needed CSS+A11yDialog script for the subscription-box + modal, if going the server-side rendering way.

FAQs

Package last updated on 19 Apr 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc