From a595b0199bd9ff027650c6f65563a069b1ea3493 Mon Sep 17 00:00:00 2001 From: Victor Westerlund Date: Sat, 23 Nov 2024 16:59:56 +0100 Subject: [PATCH] wip: 2024-11-23T06:05:10+0100 (1732338310) --- api/endpoints/work/GET.php | 15 +++++- api/src/databases/models/Work/Work.php | 4 ++ public/assets/css/pages/work.css | 63 ++++++++++++++++++++++++-- public/assets/media/icons/repo.svg | 1 + public/work.php | 43 +++++++++++++++--- public/work/timeline.php | 3 +- 6 files changed, 117 insertions(+), 12 deletions(-) create mode 100644 public/assets/media/icons/repo.svg diff --git a/api/endpoints/work/GET.php b/api/endpoints/work/GET.php index aa8dd66..bb280d9 100755 --- a/api/endpoints/work/GET.php +++ b/api/endpoints/work/GET.php @@ -15,6 +15,8 @@ require_once Path::root("src/databases/VLWdb.php"); require_once Path::root("src/databases/models/Work/Work.php"); + const PARAM_LIMIT = "limit"; + class GET_Work extends VLWdb { protected Ruleset $ruleset; @@ -49,17 +51,27 @@ ->max(parent::MYSQL_INT_MAX_LENGTH), (new Rules(WorkModel::DATE_CREATED->value)) + ->type(Type::NUMBER) + ->min(1) + ->max(parent::MYSQL_INT_MAX_LENGTH), + + (new Rules(PARAM_LIMIT)) ->type(Type::NUMBER) ->min(1) ->max(parent::MYSQL_INT_MAX_LENGTH) + ->default(parent::MYSQL_INT_MAX_LENGTH) ]); parent::__construct(Databases::VLW, $this->ruleset); } public function main(): Response { - // Use copy of search paramters as filters + // Use search parameters from model as filters $filters = $_GET; + // Unset keys not included in database model from filter + foreach (array_diff(array_keys($_GET), WorkModel::values()) as $k) { + unset($filters[$k]); + } // Do a wildcard search on the title column if provided if (array_key_exists(WorkModel::TITLE->value, $_GET)) { @@ -78,6 +90,7 @@ $response = $this->db->for(WorkModel::TABLE) ->where($filters) ->order([WorkModel::DATE_CREATED->value => "DESC"]) + ->limit($_GET[PARAM_LIMIT]) ->select([ WorkModel::ID->value, WorkModel::TITLE->value, diff --git a/api/src/databases/models/Work/Work.php b/api/src/databases/models/Work/Work.php index 0111a30..31dc079 100644 --- a/api/src/databases/models/Work/Work.php +++ b/api/src/databases/models/Work/Work.php @@ -2,7 +2,11 @@ namespace VLW\API\Databases\VLWdb\Models\Work; + use victorwesterlund\xEnum; + enum WorkModel: string { + use xEnum; + const TABLE = "work"; case ID = "id"; diff --git a/public/assets/css/pages/work.css b/public/assets/css/pages/work.css index 229ead3..25249c4 100644 --- a/public/assets/css/pages/work.css +++ b/public/assets/css/pages/work.css @@ -56,7 +56,6 @@ section.hero .item { height: 300px; position: relative; border-radius: 6px; - box-shadow: 0 0 0 2px white; } section.hero .wrapper { @@ -80,13 +79,23 @@ section.hero button { /* ### Vegivisr */ section.hero .item.vegvisir { - background-color: rgb(var(--color-vegvisir)); + --color-accent: var(--color-vegvisir); + + color: rgb(var(--color-vegvisir)); + background-color: rgba(var(--color-vegvisir), .1); +} + +section.hero .item.vegvisir .bg { + opacity: .2; } /* ### Reflect */ section.hero .item.reflect { - background: linear-gradient(0deg, rgba(215,31,5,1) 0%, rgba(233,102,102,1) 49%, rgba(251,251,251,1) 49%, rgba(215,31,5,1) 50%, rgba(215,31,5,1) 100%); + --color-accent: var(--color-reflect); + + color: rgb(var(--color-reflect)); + background-color: rgba(var(--color-reflect), .2); } /* ### Background */ @@ -122,6 +131,54 @@ section.heading svg { height: 2em; } +/* ## Featured */ + +section.featured { + display: grid; + gap: var(--padding); + grid-template-columns: repeat(3, 1fr); +} + +section.featured featured-item { + display: flex; + fill: white; + color: white; + border-radius: 8px; + flex-direction: column; + padding: var(--padding); + background-color: rgba(255, 255, 255, .1); +} + +section.featured featured-item > svg { + width: 2em; +} + +/* ### Languages */ + +section.featured featured-item .langs { + gap: 5px; + display: flex; + margin: 5px 0; +} + +section.featured featured-item .langs button { + border-radius: 4px; + background-color: rgba(255, 255, 255, .1); +} + +section.featured featured-item .langs button p::before { + content: "● "; +} + +/* ### Actions */ + +section.featured featured-item .actions { + gap: 5px; + display: flex; + padding-top: var(--padding); + margin-top: auto; +} + /* # Size queries */ @media (min-width: 460px) { diff --git a/public/assets/media/icons/repo.svg b/public/assets/media/icons/repo.svg new file mode 100644 index 0000000..3f26a8a --- /dev/null +++ b/public/assets/media/icons/repo.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/public/work.php b/public/work.php index 68e989c..b50c8f5 100644 --- a/public/work.php +++ b/public/work.php @@ -1,3 +1,9 @@ +
@@ -7,6 +13,11 @@
+
+ +

featured projects

+ +
@@ -27,13 +38,31 @@
-
- -

Featured

- +
- +

latest projects

+
+ +
+
\ No newline at end of file diff --git a/public/work/timeline.php b/public/work/timeline.php index 1bb6a5a..cd96585 100644 --- a/public/work/timeline.php +++ b/public/work/timeline.php @@ -1,6 +1,7 @@ call(Endpoints::WORK->value)->get(); + $resp_work = $api->call(Endpoints::WORK->value)->params($_GET)->get(); // Resolve tags and actions if we got work results if ($resp_work->ok) {