0.7.7 • Published 3 years ago

methone v0.7.7

Weekly downloads
159
License
-
Repository
github
Last release
3 years ago

Methone: The worlds first responsive topbar-as-a-service, or TBaaS

Because this is exactly what everybody really wanted.

All of datasektionen's systems should have the unified top bar. The TBaaS was created to ensure that all systems use the latest and greatest topbar.

Arch

Pages that wants the top-bar should include the main.js file into each page. The script loads configuration from the object methone_conf which must have been defined before including bar.js.

Fuzzyfiles

Methone provides fuzzy navigation on sites where deployed. For this to work, you might need to supply methone with an fuzzyfile, which describes what items it should be possible to search for. Once the bar is loaded, the bar will load the fuzzyfile (if specified) to learn how to fuzzy search pages on the site. Also, the master fuzzyfile will be loaded from the server.

How to use

Everything works best when the parent element is an immidiate child of the body tag. You should probably lower your page content by 50 pixels.

  <body>
    <div id="methone-container-replace"> <!-- Should be a direct child of body -->
    <nav>This will be replaced</nav>
    </div>
    ....

  <script>
    window.methone_conf = {
    system_name: "meta-tv",
    color_scheme: "cerise"
    login_text: "Login with trisslott", // Default null, null hides button
    login_href: "/login",
    links: [
      {
      str: "About us",
      href: "http://my.system.se/about-us",
      }, ...
    ]
    }
  </script>

  <script async src="//methone.datasektionen.se/bar.js"></script>
  <script>
    // The config can be updated dynamically!
    window.methone_conf.update({
    login_text: "Log out",
    login_href: "/logout"
    })
    // Only the provided keys will be updated.
  </script>

Usage as a React component

If you are building a React app it is possible to include Methone as a component directly. If you do this you will be able to also use React Router with top-bar navigation. Instead of defining a window.methone_conf you directly pass a config property on the Methone element.

  config = {
    system_name: "meta-tv",
    color_scheme: "cerise"
    links: [
    {
      str: "About us",
      href: "http://my.system.se/about-us",
    },
    <Link to="/">Home</Link>,
    <Link to="/some/href">str</Link>,
    {
      str: "Interchangable links should work",
      href: "/but/who?knows"
    }
    ]
  }

  return (
    <div>
    <Methone config={config} />
    <div>
      ...
    </div>
    </div>
  )

The implementation for Link elements is quite primitive, so they should probably follow the above format quite closely. If something else works, great, but dont count on it...

I want my links in the search!

There are two types of links, global and local. To add a global link do it need to be in the fuzzyfile.js of this repo, pull request are a good way to get your system to appear everywhere! If you want local links that are only available in your system methone looks for a fuzzyfile at /fuzzyfile. The content may be dynamically generated.

An example fuzzyfile: Search is performed on the str value.

  {
    "@type": "fuzzyfile",

    "fuzzes": [
    {
      "name": "Lokalbokning - Datasektionen.se",
      "str": "lokalbokning booking",
      "color": "#FDDE00",
      "href": "http://datasektionen.se/sektionen/lokalbokning"
    },
    {
      "name": "Mottagningen - Datasektionen.se",
      "str": "mottagningen",
      "href": "/sektionen/mottagningen"
    }
    ]
  }
0.7.7

3 years ago

0.7.6

5 years ago

0.6.6

5 years ago

0.6.5

5 years ago

0.6.4

5 years ago

0.6.3

5 years ago

0.6.2

5 years ago

0.6.1

5 years ago

0.6.0

5 years ago

0.5.0

6 years ago

0.4.3

6 years ago

0.4.2

6 years ago

0.4.1

6 years ago

0.4.0

6 years ago

0.3.12

6 years ago

0.3.11

6 years ago

0.3.10

6 years ago

0.3.9

6 years ago

0.3.8

6 years ago

0.3.7

6 years ago

0.3.6

6 years ago

0.3.5

6 years ago

0.3.4

6 years ago

0.3.3

6 years ago

0.3.2

6 years ago

0.3.1

7 years ago

0.3.0

7 years ago

0.2.11

7 years ago

0.2.10

7 years ago

0.2.9

7 years ago

0.2.8

7 years ago

0.2.7

7 years ago

0.2.6

7 years ago

0.2.5

7 years ago

0.2.4

7 years ago

0.2.3

7 years ago

0.2.2

7 years ago

0.2.1

7 years ago

0.2.0

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago

1.0.0

7 years ago