Home Reference Source
import FollowButtonController from '~/controllers/FollowButtonController.js'
public class | source

FollowButtonController

Extends:

ViewController → FollowButtonController

Creates a follow button. Expects an 'SVG' subelement for icon and a 'span' element child to contain follow/unfollow text. This uses the button classes (.button-active) in the active state.

Constructor Summary

Public Constructor
public

constructor(buttonNode: HTMLElement, auth: Auth, user: User)

Sets up follow button with button node and user.

Member Summary

Public Members
public

The icon

public

The label

public

node: HTMLElement

The node

public

The user which this will follow

Method Summary

Public Methods
public

async follow()

Followers a user

public

async toggle()

Toggles if following or not

public

async unfollow()

Unfollowers a user

Inherited Summary

From class ViewController
public static

forClass(className: string, predicate: Function, root: HTMLElement)

Creates a view controller directly for all members of a class.

public static

of(elem: string | Element): ViewController

Returns a canolical VC of an element if it exists

Public Constructors

public constructor(buttonNode: HTMLElement, auth: Auth, user: User) source

Sets up follow button with button node and user.

Override:

ViewController#constructor

Params:

NameTypeAttributeDescription
buttonNode HTMLElement

Should be a .button compliant button

auth Auth

Authorization instance

user User

User _to_ follow (expects authorized)

Public Members

public icon: SwappingViewController source

The icon

public label: SwappingViewController source

The label

public node: HTMLElement source

The node

public user: User source

The user which this will follow

Public Methods

public async follow() source

Followers a user

public async toggle() source

Toggles if following or not

public async unfollow() source

Unfollowers a user