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

@accord-coop/use-teams

v4.0.1

Published

React helper components for Microsoft Teams apps

Downloads

4

Readme

Microsoft Teams UI Controls base component

npm version npm MIT GitHub issues GitHub closed issues

This is a React hook based on the Microsoft Teams JavaScript SDK and the Fluent UI components, which is used when generating Microsoft Teams Apps using the Microsoft Teams Yeoman Generator. This fork for Accord Cooperative excludes the Fluent UI React Northstar dependency.

| @master | @preview | :--------:|:---------: Build Status|Build Status

Usage

To use this package in a Teams tab or extension import the useTeams Hook and then call it inside a functional component.

const [{inTeams}] = useTeams();

The useTeams hook will return a tuple of where an object of properties are in the first field and an object of methods in the second.

NOTE: using the hook will automatically call microsoftTeams.initialize() and microsoftTeams.getContext() if the Microsoft Teams JS SDK is available.

useTeams Hook arguments

The useTeams hook can take an optional object argument:

| Argument | Description | |----------|-------------| | initialTheme?: string | Manually set the initial theme (default, dark or contrast) | | setThemeHandler?: (theme?: string) => void | Custom handler for themes |

Available properties

| Property name | Type | Description | |---------------|------|-------------| | inTeams | boolean? | true if hosted in Teams and false for outside of Microsoft Teams | | fullScreen | boolean? | true if the Tab is in full-screen, otherwise false | | themeString | string | The value of default, dark or contrast | | context | microsoftTeams.Context? | undefined while the Tab is loading or if not hosted in Teams, set to a value once the Tab is initialized and context available |

Available methods

| Method name | Description | |-------------|-------------| | setTheme(theme?: string) | Method for manually setting the theme |

Full example

Example of usage:

import React, { useState, useEffect } from "react";
import { useTeams } from "msteams-react-base-component";

/**
 * Implementation of the hooks Tab content page
 */
export const HooksTab = () => {
    const [{ inTeams, theme }] = useTeams({});
    const [message, setMessage] = useState("Loading...");

    useEffect(() => {
        if (inTeams === true) {
            setMessage("In Microsoft Teams!");
        } else {
            if (inTeams !== undefined) {
                setMessage("Not in Microsoft Teams");
            }
        }
    }, [inTeams]);

    return (
        <div>{message}</div>
    );
};

Additional helper methods

The package also exports two helper methods, both used internally by the useTeams hook.

getQueryVariable(name: string): string - returns the value of the query string variable identified by the name.

checkInTeams(): boolean - returns true if hosted inside Microsoft Teams.

License

Copyright (c) Wictor Wilén. All rights reserved.

Licensed under the MIT license.