diff --git a/assets/js/ports.js b/assets/js/ports.js index 91e95220..a1f38d51 100644 --- a/assets/js/ports.js +++ b/assets/js/ports.js @@ -552,6 +552,9 @@ export const actions = { 'LOG': (app, session, message) => { console.log(`From Elm:`, message); }, + 'LOGERR': (app, session, message) => { + console.warn(`Error from Elm:`, message); + }, 'SHOW': (app, session, id) => { var $e = document.getElementById(id); if (!$e) { return } @@ -564,8 +567,8 @@ export const actions = { $e.style.display = "none"; //$e.style.visibility = "hidden"; }, - 'LOGERR': (app, session, message) => { - console.warn(`Error from Elm:`, message); + 'OPENINNEWTAB': (app, session, url) => { + window.open(url, '_blank'); }, 'CLICK': (app, session, target) => { if (target == "") { diff --git a/assets/sass/fractal6.scss b/assets/sass/fractal6.scss index e89d82c8..a4aca54b 100644 --- a/assets/sass/fractal6.scss +++ b/assets/sass/fractal6.scss @@ -5,10 +5,20 @@ * */ -#app.embed .is-hidden-embed { - display: none; +#app.embed { + .is-hidden-embed { + display: none !important; + } + + .columns { + } + .orgPane > .column, .orgPane > * > .column, .orgPane > * > * > .column { + padding: 0 !important; + width: 100% !important; + } } + /* * * Bulma Fixes @@ -1205,7 +1215,7 @@ figcaption { position: relative; //position: absolute; box-shadow: 0 0 1px 0 var(--is-highlight); - margin-top: 3rem; + margin-top: 4rem; padding: 1rem 1rem 1rem; } diff --git a/src/Extra/Url.elm b/src/Extra/Url.elm index 35805d37..7b0b2993 100644 --- a/src/Extra/Url.elm +++ b/src/Extra/Url.elm @@ -19,9 +19,11 @@ -} -module Extra.Url exposing (queryBuilder, queryFullBuilder, queryParser, toAnchor) +module Extra.Url exposing (getUrlQueryParam, queryBuilder, queryFullBuilder, queryParser, toAnchor) import Dict exposing (Dict) +import List.Extra as LE +import Maybe exposing (withDefault) import Url exposing (Url) @@ -105,3 +107,12 @@ toAnchor x = |> String.replace " " "-" |> String.toLower |> String.append "#" + + +getUrlQueryParam : String -> Url -> Maybe String +getUrlQueryParam key url = + url.query + |> Maybe.map (String.split "&") + |> Maybe.andThen (LE.find (String.startsWith (key ++ "="))) + |> Maybe.map (String.split "=") + |> Maybe.andThen LE.last diff --git a/src/Main.elm b/src/Main.elm index f2581d4c..3fe9df07 100644 --- a/src/Main.elm +++ b/src/Main.elm @@ -23,7 +23,7 @@ module Main exposing (main) import Browser exposing (Document) import Browser.Navigation as Nav exposing (Key) -import Extra.Url exposing (queryParser) +import Extra.Url exposing (getUrlQueryParam, queryParser) import Generated.Pages as Pages import Generated.Route as Route exposing (Route(..)) import Global exposing (Msg(..)) @@ -31,6 +31,7 @@ import Html import Ports import Session exposing (encodeViewMode) import Url exposing (Url) +import Url.Parser.Query main : Program Flags Model Msg @@ -94,7 +95,10 @@ update : Msg -> Model -> ( Model, Cmd Msg ) update msg model = case msg of LinkClicked (Browser.Internal url) -> - if Route.fromUrl url == Just Route.Logout then + if getUrlQueryParam "view" model.url == Just "embed" then + ( model, Ports.openInNewTab (Url.toString url) ) + + else if Route.fromUrl url == Just Route.Logout then ( model, Nav.replaceUrl model.key (Url.toString url) ) else diff --git a/src/Org/Project.elm b/src/Org/Project.elm index e62e9ef0..213198d7 100644 --- a/src/Org/Project.elm +++ b/src/Org/Project.elm @@ -690,7 +690,7 @@ view_ : Global.Model -> Model -> Html Msg view_ global model = div [ class "columns is-centered" ] [ div [ class "column is-12 is-11-desktop is-10-fullhd pb-0" ] - [ div [ class "columns is-centered mb-0" ] + [ div [ class "columns is-centered mb-0 is-hidden-embed" ] [ div [ class "column is-tree-quarter pb-1" ] [ case model.project_data of Success p -> diff --git a/src/Ports.elm b/src/Ports.elm index f27655b0..63b54cb8 100644 --- a/src/Ports.elm +++ b/src/Ports.elm @@ -591,6 +591,14 @@ log message = } +logErr : String -> Cmd msg +logErr message = + outgoing + { action = "LOGERR" + , data = JE.string message + } + + show : String -> Cmd msg show message = outgoing @@ -607,18 +615,18 @@ hide message = } -fitHeight : String -> Cmd msg -fitHeight message = +openInNewTab : String -> Cmd msg +openInNewTab url = outgoing - { action = "FIT_HEIGHT" - , data = JE.string message + { action = "OPENINNEWTAB" + , data = JE.string url } -logErr : String -> Cmd msg -logErr message = +fitHeight : String -> Cmd msg +fitHeight message = outgoing - { action = "LOGERR" + { action = "FIT_HEIGHT" , data = JE.string message }