Giter VIP home page Giter VIP logo

Comments (3)

nagaozen avatar nagaozen commented on July 3, 2024 1

App.js

import React, { useState } from "react"
import { Button, ButtonType } from "office-ui-fabric-react"

import Header from "./Header"
import HeroList from "./HeroList"
import Progress from "./Progress"

const handleClick = (event) => Word.run(async context => {
  const paragraph = context.document.body.insertParagraph("Hello World", Word.InsertLocation.end)
  paragraph.font.color = "blue"
  await context.sync()
})

const App = ({ title, isOfficeInitialized }) => {
  const [listItems, setListItems] = useState([
    { icon: "Ribbon", primaryText: "Achieve more with Office integration" },
    { icon: "Unlock", primaryText: "Unlock features and functionality" },
    { icon: "Design", primaryText: "Create and visualize like a pro" }
  ])

  if (!isOfficeInitialized) {
    return (
      <Progress title={title} logo="assets/logo-filled.png" message="Please sideload your addin to see app body." />
    );
  }

  return (
    <div className="ms-welcome">
      <Header logo="assets/logo-filled.png" title={title} message="Welcome" />
      <HeroList message="Discover what Office Add-ins can do for you today!" items={listItems}>
        <p className="ms-font-l">
          Modify the source files, then click <b>Run</b>.
        </p>
        <Button
          className="ms-welcome__action"
          buttonType={ButtonType.hero}
          iconProps={{ iconName: "ChevronRight" }}
          onClick={handleClick}
        >Run</Button>
      </HeroList>
    </div>
  )
}

export default App

Header.js

import React from 'react'

const Header = ({ title, logo, message }) => (
  <section className='ms-welcome__header ms-bgColor-neutralLighter ms-u-fadeIn500'>
    <img width='90' height='90' src={logo} alt={title} title={title} />
    <h1 className='ms-fontSize-su ms-fontWeight-light ms-fontColor-neutralPrimary'>{message}</h1>
  </section>
)

export default Header

HeroList.js

import React from 'react'

const HeroList = ({ children, items, message }) => {
  const listItems = items.map((item, index) => (
    <li className='ms-ListItem' key={index}>
      <i className={`ms-Icon ms-Icon--${item.icon}`} />
      <span className='ms-font-m ms-fontColor-neutralPrimary'>{item.primaryText}</span>
    </li>
  ))

  return (
    <main className='ms-welcome__main'>
      <h2 className='ms-font-xl ms-fontWeight-semilight ms-fontColor-neutralPrimary ms-u-slideUpIn20'>{message}</h2>
      <p>Hello World</p>
      <ul className='ms-List ms-welcome__features ms-u-slideUpIn10'>{listItems}</ul>
      {children}
    </main>
  )
}

export default HeroList

Progress.js

import React from 'react'
import { Spinner, SpinnerType } from 'office-ui-fabric-react'

const Progress = ({ logo, message, title }) => (
  <section className='ms-welcome__progress ms-u-fadeIn500'>
    <img width='90' height='90' src={logo} alt={title} title={title} />
    <h1 className='ms-fontSize-su ms-fontWeight-light ms-fontColor-neutralPrimary'>{title}</h1>
    <Spinner type={SpinnerType.large} label={message} />
  </section>
)

export default Progress

from office-addin-taskpane-react-js.

igor-ribeiiro avatar igor-ribeiiro commented on July 3, 2024

Hey @sethachoi, I guess the commentary given gave some samples to help you if you are still facing the issue.
I will be closing this issue for now but feel free to reopen it if you still need help.

from office-addin-taskpane-react-js.

Rick-Kirkham avatar Rick-Kirkham commented on July 3, 2024

@sethachoi The project generated from this repo's template has just been updated to use hooks.

from office-addin-taskpane-react-js.

Related Issues (13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.