0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-02-08 08:09:14 -05:00

Merge pull request #159 from tokens-studio/sizing-token-context-menu

Add context menu functionalities on sizing tokens
This commit is contained in:
Akshay Gupta 2024-06-04 15:47:58 +05:30 committed by GitHub
commit e8b755c757
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 55 additions and 33 deletions

View file

@ -14,7 +14,7 @@ values:
image: image:
pullPolicy: IfNotPresent pullPolicy: IfNotPresent
repository: ghcr.io/tokens-studio/tokens-studio-for-penpot repository: ghcr.io/tokens-studio/tokens-studio-for-penpot
tag: 'frontend-pr-{{ .SHA }}' tag: 'frontend-{{ .SHA }}'
ingress: ingress:
hosts: hosts:
- host: "{{ .BRANCH | sanitizeDNSName }}.penpot.staging.tokens.studio" - host: "{{ .BRANCH | sanitizeDNSName }}.penpot.staging.tokens.studio"

View file

@ -116,6 +116,7 @@ manifests: |
enabled: true enabled: true
annotations: annotations:
cert-manager.io/cluster-issuer: letsencrypt-prod cert-manager.io/cluster-issuer: letsencrypt-prod
networking.gke.io/v1beta1.FrontendConfig: default-frontend-config
hosts: hosts:
- host: penpot.tokens.studio - host: penpot.tokens.studio
tls: tls:

View file

@ -12,8 +12,7 @@ jobs:
matrix: matrix:
include: include:
- dockerfile: Dockerfile.frontend - dockerfile: Dockerfile.frontend
type: pr-frontend type: frontend
name: frontend
permissions: permissions:
contents: read contents: read
packages: write packages: write
@ -31,7 +30,7 @@ jobs:
with: with:
registry: ghcr.io registry: ghcr.io
username: ${{ github.actor }} username: ${{ github.actor }}
password: ${{ secrets.PAT_TOKEN }} password: ${{ secrets.GHCR_TOKEN }}
- name: Docker meta - name: Docker meta
id: meta id: meta
@ -43,9 +42,9 @@ jobs:
ghcr.io/tokens-studio/tokens-studio-for-penpot ghcr.io/tokens-studio/tokens-studio-for-penpot
- name: prebuild - name: prebuild
run: | run: |
echo "Building ${{ matrix.name }} image" echo "Building ${{ matrix.type }} image"
./manage.sh build-${{matrix.name}}-bundle ./manage.sh build-${{matrix.type}}-bundle
mv ./bundles/${{matrix.name}} ./docker/images/bundle-${{matrix.name}}/ mv ./bundles/${{matrix.type}} ./docker/images/bundle-${{matrix.type}}/
- name: Publish Docker images - name: Publish Docker images
uses: docker/build-push-action@v5 uses: docker/build-push-action@v5
@ -68,4 +67,3 @@ jobs:
env: env:
GIMLET_SERVER: ${{ secrets.GIMLET_SERVER }} GIMLET_SERVER: ${{ secrets.GIMLET_SERVER }}
GIMLET_TOKEN: ${{ secrets.GIMLET_TOKEN }} GIMLET_TOKEN: ${{ secrets.GIMLET_TOKEN }}
DEPLOY: 'true'

View file

@ -31,8 +31,7 @@ jobs:
with: with:
registry: ghcr.io registry: ghcr.io
username: ${{ github.actor }} username: ${{ github.actor }}
password: ${{ secrets.PAT_TOKEN }} password: ${{ secrets.GHCR_TOKEN }}
- name: Docker meta - name: Docker meta
id: meta id: meta
@ -72,7 +71,7 @@ jobs:
with: with:
ENV: "prod" ENV: "prod"
APP: "penpot" APP: "penpot"
WAIT: "true" DEPLOY: "true"
smoke: smoke:
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: needs:

View file

@ -77,10 +77,10 @@
[:map [:map
[:width {:optional true} ::sm/uuid] [:width {:optional true} ::sm/uuid]
[:height {:optional true} ::sm/uuid] [:height {:optional true} ::sm/uuid]
[:min-height {:optional true} ::sm/uuid] [:layout-item-min-w {:optional true} ::sm/uuid]
[:max-height {:optional true} ::sm/uuid] [:layout-item-max-w {:optional true} ::sm/uuid]
[:min-width {:optional true} ::sm/uuid] [:layout-item-min-h {:optional true} ::sm/uuid]
[:max-width {:optional true} ::sm/uuid]]) [:layout-item-max-h {:optional true} ::sm/uuid]])
(def sizing-keys (schema-keys ::sizing)) (def sizing-keys (schema-keys ::sizing))

View file

@ -13,6 +13,7 @@
[app.main.data.tokens :as dt] [app.main.data.tokens :as dt]
[app.main.data.workspace.changes :as dch] [app.main.data.workspace.changes :as dch]
[app.main.data.workspace.shape-layout :as dwsl] [app.main.data.workspace.shape-layout :as dwsl]
[app.main.data.workspace.transforms :as dwt]
[app.main.refs :as refs] [app.main.refs :as refs]
[app.main.store :as st] [app.main.store :as st]
[app.main.ui.components.dropdown :refer [dropdown]] [app.main.ui.components.dropdown :refer [dropdown]]
@ -54,12 +55,35 @@
(st/emit! (dwsl/update-layout shape-ids {:layout-padding (zipmap attributes (repeat value))})))) (st/emit! (dwsl/update-layout shape-ids {:layout-padding (zipmap attributes (repeat value))}))))
(defn apply-spacing-token [{:keys [token-id token-type-props selected-shapes]} attribute] (defn apply-spacing-token [{:keys [token-id token-type-props selected-shapes]} attributes]
(let [token (dt/get-token-data-from-token-id token-id) (let [token (dt/get-token-data-from-token-id token-id)
attribute (set attribute) attributes (set attributes)
updated-token-type-props (assoc token-type-props updated-token-type-props (assoc token-type-props
:on-update-shape update-layout-spacing :on-update-shape update-layout-spacing
:attributes attribute)] :attributes attributes)]
(wtc/on-apply-token {:token token
:token-type-props updated-token-type-props
:selected-shapes selected-shapes})))
(defn update-shape-dimensions [value shape-ids attributes]
(st/emit! (dwt/update-dimensions shape-ids (first attributes) value)))
(defn update-layout-sizing-limits [value shape-ids attributes]
(st/emit! (dwsl/update-layout-child shape-ids {(first attributes) value})))
(defn apply-sizing-token [{:keys [token-id token-type-props selected-shapes]} attributes]
(let [token (dt/get-token-data-from-token-id token-id)
updated-token-type-props (cond
(set/superset? #{:width :height} attributes)
(assoc token-type-props
:on-update-shape update-shape-dimensions
:attributes attributes)
(set/superset? {:layout-item-min-w :layout-item-max-w
:layout-item-min-h :layout-item-max-h} attributes)
(assoc token-type-props
:on-update-shape update-layout-sizing-limits
:attributes attributes))]
(wtc/on-apply-token {:token token (wtc/on-apply-token {:token token
:token-type-props updated-token-type-props :token-type-props updated-token-type-props
:selected-shapes selected-shapes}))) :selected-shapes selected-shapes})))
@ -90,6 +114,17 @@
{:title "Right" :attributes #{:p2}} {:title "Right" :attributes #{:p2}}
{:title "Bottom" :attributes #{:p3}} {:title "Bottom" :attributes #{:p3}}
{:title "Left" :attributes #{:p4}}]) {:title "Left" :attributes #{:p4}}])
:sizing (attributes->actions
apply-sizing-token
[{:title "All" :attributes #{:width :height :layout-item-min-w :layout-item-max-w :layout-item-min-h :layout-item-max-h}}
{:title "Width" :attributes #{:width}}
{:title "Height" :attributes #{:height}}
{:title "Min width" :attributes #{:layout-item-min-w}}
{:title "Max width" :attributes #{:layout-item-max-w}}
{:title "Min height" :attributes #{:layout-item-min-h}}
{:title "Max height" :attributes #{:layout-item-max-h}}])
[]))) [])))
(defn generate-menu-entries [{:keys [token-id token-type-props token-type selected-shapes] :as context-data}] (defn generate-menu-entries [{:keys [token-id token-type-props token-type selected-shapes] :as context-data}]

View file

@ -24,19 +24,8 @@
background-color: var(--menu-background-color); background-color: var(--menu-background-color);
max-height: 100vh; max-height: 100vh;
overflow-y: auto; overflow-y: auto;
// TODO: Fixes missing styles from parent context menu
li {
@include bodySmallTypography;
color: var(--menu-foreground-color);
}
} }
// TODO: Allow selected items wihtout an icon for the context menu .token-context-submenu {
.empty-icon { position: absolute;
width: 0;
height: 0;
}
.hidden-icon {
width: 11px;
} }